asp.net – ASPXGridView ClientSideEvents如何获取所选行的KeyField值
发布时间:2020-05-24 01:04:52 所属栏目:asp.Net 来源:互联网
导读:我试图在客户端获取选定的网格行KeyField值; 我曾经尝试过以下各种结果: 方法#1 ClientSideEvents RowClick=function(s, e) {var key= grid.GetSelectedKeysOnPage()[0];} ///This gives previous selected rows value everytime 方法#2 Client
|
我试图在客户端获取选定的网格行KeyField值; 我曾经尝试过以下各种结果: 方法#1 <ClientSideEvents RowClick="function(s,e) {var key= grid.GetSelectedKeysOnPage()[0];}" />
//This gives previous selected rows value everytime
方法#2 <ClientSideEvents RowClick="function(s,e) { grid.GetRowValues(grid.GetFocusedRowIndex(),'MyKeyFieldName',OnGetRowValues); }" />
//This gives previous selected row and also gives an error: "A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure.. blabla" But the MyKeyFieldName is true and i dont want to make a callback,i dont want to use this method!
方法#3 <ClientSideEvents RowClick="function(s,e) { grid.GetRowValues(e.visibleIndex,OnGetRowValues); }">
//This gives the same result with Method #2
问题是:如何在客户端RowClick事件中收集(不是以前的但是)当前所选行的KeyField值,而不用回调或回发? 解决方法
这两种方法都需要对服务器进行回调. 确保您已经指定了行选择操作所需的ASPxGridView.KeyFieldName属性.
处理客户端ASPxClientGridView.SelectionChanged事件; 确定刚刚通过“e.isSelected”属性选择的行; 通过客户端ASPxClientGridView.GetRowKey方法确定行的keyValue. 通过“e.visibleIndex”属性作为参数: <ClientSideEvents SelectionChanged="function(s,e) {
if (e.isSelected) {
var key = s.GetRowKey(e.visibleIndex);
alert('Last Key = ' + key);
}
}" /> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 身份验证 – 向webapi承载令牌添加额外的详细信息
- asp.net – Sys.WebForms.PageRequestManagerServerErrorEx
- asp.net – 如果表单字段为空,如何将NULL插入数据库
- asp.net-mvc – 是否可以在基于路由的MVC4中使用不同的布局
- 如何使用ASP.NET Repeater删除尾随逗号?
- asp.net-mvc – 模型绑定不起作用
- asp.net-mvc – 在asp.net mvc中存储和检索用户的设置
- asp.net-mvc-3 – 模型binder属性类型int的问题
- asp.net-mvc-3 – 如何在ASP.NET MVC 3中更新EF 4实体?
- asp.net-mvc – 设置Kendo UI Grid Popup(MVC)的宽度
推荐文章
站长推荐
- asp.net – DirectoryServicesCOMException 8007
- asp.net-mvc – 构建为单个ASP.NET MVC应用程序的
- asp.net – 在IIS中有类似cron作业的东西吗?
- 在ASP.NET中使用回发的jQuery模态对话框
- .net – ReportViewer 2010无法评估表达式
- asp.net-mvc – 具有输出参数的ExecuteSqlComman
- 在Azure中设置ASP.NET 5 Web应用程序的SQL连接字
- asp.net-mvc – ASP.NET MVC Beta 1:DefaultMod
- 使用C#读取dbf行情文件
- asp.net – 在部分视图中强制使用没有Html.Begin
热点阅读
