inserting control in ItemDataBound

  • Thread starter Thread starter Steve Klett
  • Start date Start date
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
 
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...
 
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...
 
Back
Top