inserting control in ItemDataBound

S

Steve Klett

Hi-

I am developing a hierarchical navigation system. I have a DataList with
the root level items, on the ItemDataBound event, I check for the selected
item, when found I'm adding an additional DataList Control to display the
sub items. Pretty standard.

I now realize that I don't know how to format this newly added Datalist. I
am binding a complex type to it, so I need to have DataBinder.Eval() calls,
etc... but HOW can I do that? The control doesn't exist in any aspx page,
so I don't have access to the html.

Does this make sense? I hope so. If you have any suggestions, please let
me know.

Thanks,
Steve
 
E

Edward

you need to create a function and add that function to
your newly created datalist's itemdatabound event. You
could do your formatting within that function.

example:
//your function
newItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
//do your formatting here
}

//add this to your newly created datalist
newDataList.ItemDataBound += new
System.Web.UI.WebControls.DataListItemEventHandler
(newItemDataBound);

Hope this helps...
 
S

Steve Klett

Yes, this did help. Thank a lot!!



Edward said:
you need to create a function and add that function to
your newly created datalist's itemdatabound event. You
could do your formatting within that function.

example:
//your function
newItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
//do your formatting here
}

//add this to your newly created datalist
newDataList.ItemDataBound += new
System.Web.UI.WebControls.DataListItemEventHandler
(newItemDataBound);

Hope this helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top