【发布时间】:2018-08-14 19:57:07
【问题描述】:
【问题讨论】:
标签: asp.net entity-framework telerik entity-framework-6
【问题讨论】:
标签: asp.net entity-framework telerik entity-framework-6
最简单的方法是使用DataKeyNames 属性。
<asp:GridView ID="GridView1" runat="server" DataKeyNames="SKU">
然后您可以根据行索引访问正确的 DataKeyNames。
protected void On_Update_Click(object sender, EventArgs e)
{
//cast the sender back to a control and get the gridviewrow from the namingconainer
GridViewRow row = (GridViewRow)(((Control)sender).NamingContainer);
//get the gridview itself from the gridviewrow
GridView gv = row.Parent.Parent as GridView;
//get the correct datakey from the gridview with the dataitemindex
int SKU = Convert.ToInt32(gv.DataKeys[row.DataItemIndex].Values[0]);
//display result
Label1.Text = SKU.ToString();
}
【讨论】: