I group my data by length as follows
int[] a = { 1, 2, 3,45,45,100,566};
var result =
a.GroupBy(x => x.ToString().Length).
Select(d => n开发者_运维技巧ew { Key = d.Key, Grp = d });
My BulletedList is nested in GridView(placed as template field) to display the items,What is the way to bind the BulletedList when GridView displays "Key".
GridView1.DataSource = result;
GridView1.DataBind();
set DataKeyNames
to your key name
For example:
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
emptydatatext="No data available."
autogenerateselectbutton="true"
datakeynames="CustomerID"
Binding to a bulleted list within a gridview (works similarly for any control, of course)
void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
RadioButtonList list = (RadioButtonList)e.Row.FindControl("rbList");
if(list != null)
{
list.DataSource = mysource;
list.DataBind();
}
}
}
Make sure you add the event to the GridView.
精彩评论