Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags).
I would pro
I would definitely avoid the second approach - you don't want to hit the database everytime you databind a parent item. As DOK says, try and architect your system properly. For me that would mean populating a collection of business objects and binding to it. I do something similar with a custom menu control (note this nests three datalists, but you could use repeaters):
In the aspx page:
//your object
//your object's child items
//child item's child items
then in the code behind:
protected void dlMenu_ItemDataBound(object sender, DataListItemEventArgs e)
{
DataListItem parentList = e.Item;
DataList dlMenuTwo = (DataList)parentList.FindControl("dlMenuTwo");
MenuItem item = (MenuItem)parentList.DataItem;
dlMenuTwo.DataSource = _menu.GetChildItems(item);
dlMenuTwo.DataBind();
}
this method basically gets a reference to the object being bound (parentList.DataItem) and then binds the nested DataList to the child items (_menu.GetChildItems(item))