ASP.NET/C#Linq绑定到GridView

ASP.NET/C#Linq绑定到GridView,c#,asp.net,gridview,C#,Asp.net,Gridview,我将数据按长度分组如下 int[] a = { 1, 2, 3,45,45,100,566}; var result = a.GroupBy(x => x.ToString().Length). Select(d => new { Key = d.Key, Grp = d }); 我的BulletedList嵌套在GridView(作为模板字段放置)中以显示项目,当GridView显示“键”时,绑定BulletedList的方法是什么 将DataKeyNames设置为密钥名

我将数据按长度分组如下

int[] a = { 1, 2, 3,45,45,100,566};

var result =
 a.GroupBy(x => x.ToString().Length).
 Select(d => new { Key = d.Key, Grp = d });
我的BulletedList嵌套在GridView(作为模板字段放置)中以显示项目,当GridView显示“键”时,绑定BulletedList的方法是什么


DataKeyNames
设置为密钥名

例如:

<asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        autogenerateselectbutton="true"    
        datakeynames="CustomerID"

绑定到gridview中的项目符号列表(当然,对于任何控件都类似)


确保将事件添加到GridView。

+1获得正确答案,但与问题相关:add GridView1.DataKeyNames=“Key”;就在数据绑定()之前
<asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        autogenerateselectbutton="true"    
        datakeynames="CustomerID"
 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();
      }
    }
   }