asp.net – ASPXGridView ClientSideEvents如何获取所选行的KeyF
发布时间:2020-12-15 23:41:28 所属栏目:asp.Net 来源:网络整理
导读:我试图在客户端获取选定的网格行KeyField值; 我曾经尝试过以下各种结果: 方法#1 ClientSideEvents RowClick="function(s,e) {var key= grid.GetSelectedKeysOnPage()[0];}" ///This gives previous selected rows value everytime 方法#2 ClientSideEvents
我试图在客户端获取选定的网格行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); } }" /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – Asp.net Mvc:Ninject – IPrincipal
- asp.net-mvc-3 – 如何删除不需要的WWW-Authenticate标头
- asp.net-mvc – 使用IoC在Controller中注入HttpContextBase
- asp.net – 使用XML Schema和OpenXML SDK进行WordML模板化
- asp.net-mvc – 如何使用Moq测试一个自定义的ModelBinder?
- asp.net-mvc – 防止XSS攻击,仍然使用Html.Raw
- asp.net – Application_EndRequest没有找到Session
- 来自ASP.Net PageMethod Call的访问响应标头
- asp.net – DataMember Emit默认值
- asp.net-mvc – 使用ASP.NET MVC的Piranha CMS路由问题
推荐文章
站长推荐
- asp.net-mvc – ASP.NET MVC中的所有内置ActionR
- asp.net – WPF初学者澄清
- telerik – 在向网格添加行时,具有ASP.NET MVC3的
- entity-framework – 如何升级EF Core Tools
- asp.net – 在UserControl中将选定值设置为DropD
- asp.net-mvc – ASP.NET MVC门户可用吗?
- asp.net – 此行已经属于另一个表
- .net – 为什么使用DirectoryEntry对LDAP进行身份
- asp.net-mvc – Cookie中的ASP.NET MVC Store Te
- asp.net – asp mvc http以对象作为参数获取动作
热点阅读