如何使用C#在asp.net中获取gridview行值 [英] how to get gridview row values in asp.net using C#

查看:66
本文介绍了如何使用C#在asp.net中获取gridview行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gridview中如下



In gridview as follows

           Column1   Column2    Column3      Column4    Column5
            Name      Age      Dateofbirth     address    pincode

select       Ram       25      25/9/1985       chennai    600033   (first row)
select       Sam       23      20/8/1984       chennai    600002   (second row)







i希望获得第二排和第五列价值



当我点击gridview中的第二行我想得到第二排第5列的选定行5



输出如下

600002



我怎么能在asp.net中使用charp。




i want to get the second row and 5th column value

When i click the second row in gridview i want to get the selected row of 2nd row 5th column5

Output as follows
600002

for that how can i do in asp.net using charp.

推荐答案

嘿,简单的答案是使用LinkBut​​ton或任何其他按钮,并使用CommandName和CommandArgument属性并传递CommandArgument是传递给Tex时的当前单元格值t字段并使用该CommandArgument,您可以轻松获取当前单元格值。



Hey the simple answer is use LinkButton or any other buttons, and use CommandName and CommandArgument properties and pass CommandArgument is the current cell value as you pass to Text field and using that CommandArgument you can easily get the current cell value.

<ItemTemplate>
         <asp:LinkButton ID="lnkbtn" runat="server" Text='<%#Eval("ID")%>'

          CommandArgument=
          '<%#Eval("ID") %>'

              CommandName="Get" />
        </ItemTemplate>





和onrowcommand事件你可以通过传递commandname和commandargument来获取单元格值。



and onrowcommand event you can get the cell value by passing commandname and commandargument.


这篇关于如何使用C#在asp.net中获取gridview行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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