当我单击 Telerik RadGrid 上的一行时,我可以触发以下方法。我可以引用任何列,例如 item["Description"]
问题:如何引用'Id'的DataKeyName
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="LinqDataSource1" GridLines="None" OnItemDataBound="materialsGrid_ItemDataBound" OnItemCommand="RadGrid1_ItemCommand">
<ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="Id" DataSourceID="LinqDataSource1" CssClass="listItems"
Width="98%">
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
GridDataItem item = (GridDataItem)e.Item;
string str = item["Description"].Text;
var Id = item["Id"];