Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code not firing?

Status
Not open for further replies.

overDeveloper

Programmer
Dec 11, 2006
58
US
I ahve the follwoing code in a control:

Code:
<%@Import namespace="System.Data"%>
<%@Import namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
DataSet nodeDS = new DataSet();
dataSet GetNodes() {
   SqlDataAdapter nodeAptr = new Sql........
   nodeAptr.Fill(nodeDS, "nodes");
   return nodeDS;
}
</script>

<asp:Repeater id="rptr_nodes" runat="server" datasource="<%#GetNodes()%>">

.......

</asp:Repeater>

I try to even screw up the connection for the adapter and it does not error out... it's like it is not even trying it... see anything wrong?
[/code]
 
The problem with that is that the code that is being produced is xml for a tree node and it seems to fire that code before the code behind so it will not work if it created in the code behind....
 
It will work so I'd suggest trying it before dismissing the solution offered to you. Create a code behind page, create your function and then call that function from your page load event.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Again, the issue is that the treenode XML is served BEFORE the code behind - so trying to build the xml in the code behind does not work as the aspx page is served without the xml being built yet... make sense?

Not trying to make trouble... if seeing the code would help - I'd be glad to provide it...
 
No, it doesn't make sense. How can xml be served to the client before your server-side code has been executed? An example of what you have done via the code-behind approach will show us what you are possibly doing wrong.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
I understand you.

What is building the treenode XML?

I guess my point is that EVERYTHING should be in the code behind. You should never have to use "<% %>" in an aspx page.

Senior Software Developer
 
Here is a sample of the .net code (that creates xml code) that I need to create (an IE Web Control):

Code:
<iewc:TreeView id......>
    <iewc:TreeNode Text="xxx" expand="true">
        <iewc:TreeNode Text="aaa"></iewc:TreeNode>
    </iewc:TreeNode>
<iewc:TreeView>

This code gets served by the server (not client) before the code behind... this is the code I need to dynamically create.....
 
That still doesn't make sense to me. Firstly, I don't understand what XML has to do with the problem as from your first post, you wanted to bind a repeater control and now you want to create a new instance of a TreeView control.

If you want to dynamically create controls, you can do so like in this example. If not, you'll need to explain exactly what you want.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top