The Container.DataItem will be the Key of the item in your NameValueCollection. To get the Value right, you'll have to handle the ItemBound event of your Repeater:
this.DataViewer.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(DataViewer_ItemDataBound);
The handler looks something like this:
private void DataViewer_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
string key = e.Item.DataItem as string;
Literal Value = e.Item.FindControl("Value") as Literal;
Value.Text = _SomeData.Get(key);
}
}
eric zhou
Member
261 Points
62 Posts
How to bind NameValueCollection's Values to repeater control?
Aug 11, 2006 09:26 AM|LINK
How to bind NameValueCollection's Values to repeater control?
How should I map the property?
Mark van Dij...
Member
5 Points
1 Post
Re: How to bind NameValueCollection's Values to repeater control?
Sep 25, 2006 12:57 PM|LINK
Binding the NameValueCollection to for instance a Repeater will only give you access to the Keys.
You'll find that the DataItem is actually a string.
One way to do this is the following:
Repeater definition in .aspx:
The Container.DataItem will be the Key of the item in your NameValueCollection.To get the Value right, you'll have to handle the ItemBound event of your Repeater: