asp.net – 如何从Telerik RadGrid获
发布时间:2020-05-23 03:21:21 所属栏目:asp.Net 来源:互联网
导读:telerik:RadGrid ID=radGrid runat=server AllowPaging=true AllowCustomPaging=True GridLines=None PageSize=20 AllowMultiRowSelection=true ClientSettings-Selecting-AllowRowSelect=true
<telerik:RadGrid ID="radGrid" runat="server" AllowPaging="true" AllowCustomPaging="True"
GridLines="None" PageSize="20" AllowMultiRowSelection="true" ClientSettings-Selecting-AllowRowSelect="true"
AutoGenerateColumns="false" onneeddatasource="radGrid_NeedDataSource" OnItemCreated="radGrid_ItemCreated"
OnItemDataBound="radGrid_ItemDataBound" OnItemCommand="radGrid_ItemCommand"
DataKeyNames="ClientID">
<mastertableview datakeynames="ID" gridlines="None" width="100%">
<PagerTemplate> and so on ... </telerik:RadGrid>
情况: – 以上是我正在使用的Telerik RagGrid控件的标记.我试图访问GridColumn的KeyValue,通常的方式, Int32 key = Convert.ToInt32((e.Item as GridDataItem).GetDataKeyValue("ID"));
这不行.有替补吗? 解决方法请尝试以下代码片段.protected void RadGrid1_ItemDataBound(object sender,GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
// NORMAL MODE
GridDataItem item = e.Item as GridDataItem;
string strId = item.GetDataKeyValue("ID").ToString();
}
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
if (e.Item is GridEditFormInsertItem)
{
// INSERT MODE
GridEditableItem editedItem = e.Item as GridEditableItem;
}
else
{
// EDIT MODE
GridEditableItem editedItem = e.Item as GridEditableItem;
string strId = editedItem.GetDataKeyValue("ID").ToString();
}
}
}
protected void RadGrid1_ItemCommand(object sender,GridCommandEventArgs e)
{
if (e.CommandName == "YourCommandName")
{
GridDataItem item = e.Item as GridDataItem;
string strId = item.GetDataKeyValue("ID").ToString();
}
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – MVC @ Url.Content vs @ Url.Action
- 如何在.NET MVC应用程序中包含社交媒体共享?
- ASP.NET MVC – 如何从局部视图中获取当前操作?
- asp.net – 获取Gridview中隐藏列的值
- asp.net-mvc – 避免“类或CssClass值未定义”ASP.NET MVC中
- asp.net – Web api界面在本地工作,但不在Azure上
- asp.net-mvc – 任何潜在的安全风险设置,打开relaxedUrlToF
- asp.net-mvc – @ Html.ActionLink如何添加一个查询字符串
- asp.net-mvc – 在ASP.NET MVC中的View和PartialView有什么
- asp.net-mvc – 通过WCF服务实现寻呼机
推荐文章
站长推荐
- 启动asp.net输出缓存
- asp.net-mvc – 如何使用MVC 4上传大文件?
- asp.net-mvc – 如何在ASP.NET MVC中使用编译的全
- Asp.net mvc – 获取上传文件的完整文件名
- asp.net-mvc – 如何阻止URL.Action包含参数?
- asp.net-core – compilationOptions.emitEntryP
- asp-classic – 经典的ASP页面是否会运行在Windo
- asp.net – Internet Explorer 11在服务器端的检
- asp.net-mvc-3 – mvc3 OutputCache RemoveOutpu
- asp.net – Jquery datepicker:验证日期mm/dd/y
热点阅读
