如何在 Telerik RadGrid 中选择行?
当用户在 Telerik Rad Grid 中选择一行时,我想获取该行中的字段。怎么办?
When user select a row in Telerik Rad Grid, i want to take fields in this row. how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这有点棘手,但完成一次后就很容易了。
第 1 步。
转到 Radgrid 本身并编辑字段 DataKeyNames=""(在 MasterTableView 下),然后添加您要提取的数据字段:
第 2 步。
决定如何进行要获取值,请在“行更改”(SelectedIndexChanged) 上或按下带有附加命令的按钮 (ItemCommand)。
如果行发生变化,根据您的问题:
这会将变量“z”分配给您在该给定行中选择的列的值 (ColumnNameFromSqlGoesHere)。
如果您希望每次更改行时选择多个变量,则需要在 DataKeyNames=" " 下添加您希望选择的所有值。 (以逗号分隔)。然后,您将通过 SelectedIndexChanged 方法中看到的代码获取每个值:
等等...您明白了。
It's a little tricky, but easy after you've done it once.
Step 1.
Go to the Radgrid itself and edit the field DataKeyNames="" (under MasterTableView) and add the datafield you are pulling:
Step 2.
Decide how you are going to grab the values, on Row Change (SelectedIndexChanged) or on a buttong press with a command attached to it (ItemCommand).
If row change, per your question:
This will assign the variable "z" to the value of the column you have chosen (ColumnNameFromSqlGoesHere) at that given row.
If you wish to select multiple variables every time you change row you need to add all the values you wish to select under the DataKeyNames=" ". (Seperated by commas). You would then fetch each value via the code seen in the SelectedIndexChanged method:
Etc... You get the idea.
这应该能让你继续前进。这是直接来自 Telerik 的解决方案:检索所选项目的主键值
This should get you going. It is a solution straight from Telerik: Retrieving primary key values for selected items
试试这个。这可能对你有帮助。
第 1 步:在 radgrid 中添加一个单选按钮列
第 1 步:获取 radgrid 中所选行的主键。
if 中的行 条件将用于通过更改字段数据键名称来获取所选行中的字段,即将“ID”更改为其他字段
阅读本文了解更多详细信息...
http://codedotnets.blogspot.in/2012/01/get -primary-key-selected-radiobutton.html
Try this. This may help you.
STEP 1:Add one radiobutton column in the radgrid
STEP 1: Get the primary key of selected row in the radgrid.
Line in the if condition will be used to get the fields from the selected row just by changing the fields datakey name i.e. changing "ID" to other field
Read this article for more details...
http://codedotnets.blogspot.in/2012/01/get-primary-key-selected-radiobutton.html