如何使用命令扩充和命令名称获取选择行的行值 [英] how to get row values for select row using command augment and command name

查看:76
本文介绍了如何使用命令扩充和命令名称获取选择行的行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在asp.net中使用网格视图,我想使用命令扩充和命令名称从行中获取选定的行值.
我能够获得一个绑定到该链接按钮的值,但不是所有值.

我也在尝试通过行索引获取它.

请帮帮我.

问候

Bilal

Hi all,

I am using grid view in asp.net,and I want to fetch selected row values from the row using command augment and command name.
I am able to get one value which is bind to that link button but not all the values.

I am also trying to get it through row index.

Please help me.

Regards

Bilal

推荐答案


比拉


这是获取选定或单击的行的值(必须在Gridview数据键中定义)的解决方案.

Hi,
Bila


Here is the solution to get the Values (Must defined in Gridview Datakeys) of the selected or clicked row.

'It will find linkbutton in gridview container
Dim gvr As GridViewRow = CType(CType(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
Dim intRow As Integer
'The container will return a selected row
intRow = gvr.RowIndex
'Assin keys of selected rows to datakey variable
Dim key As DataKey = gvPayment.DataKeys(intRow)
'Access the value (that you want) that will defined in Datakey
Dim tt As String = Convert.ToString(key("TransactionType"))




请提供评分,如果对您有帮助的话:)

谢谢,
Imdadhusen




Please provide rating, if it would be helpfull to you :)

Thanks,
Imdadhusen


在命令参数中,您可以连接特定命令所需的所有参数.然后在获取命令名称的同时,将参数拆分回..

例如:


CommandArgument =''<%#Eval("mid")+"|" + Eval("msgfrom")+"|" + Eval("subject")%>

拆分;;
In command argument , u can concatenate all the arguments which u need for the particular command . And then while getting the command name , split back the arguments..

For example:


CommandArgument=''<%# Eval("mid")+"|"+ Eval("msgfrom")+"|"+Eval("subject") %>

Split;;
if (e.CommandName == "Cname")
            {
                string delimStr = "|";
                char[] delimiter = delimStr.ToCharArray();
                string[] arguments = Convert.ToString(e.CommandArgument).Split(delimiter);



谢谢!



Thanks!


感谢Imdadhusen
感谢您的努力.但是我正在用C#编写代码.
另外,如果您可以提供其他解决方案...


谢谢
thanks Imdadhusen
i appreciate your effort .but i am coding in c# .
Also if you can provide me another solution...


thanks


这篇关于如何使用命令扩充和命令名称获取选择行的行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆