Gridview:如何获取选定的行单元格值? [英] Gridview: how to get the selected row cell value?

查看:66
本文介绍了Gridview:如何获取选定的行单元格值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图,其中包含两个包含LINKBUTTON(删除和编辑)的模板字段.

单击删除按钮以在sql查询中使用时,如何获取同一行中单元格的值?

请帮助

I have a grid view with two template fields containing LINKBUTTON(DELETE and EDIT).

How can I get the value of a cell in the same row when I click on the delete button, to use in sql query?

Please help

推荐答案

在linkbutton的commandargument属性中传递您的值.

例如:


Pass your value in linkbutton''s commandargument property.

Ex:


<asp:LinkButton CommandName="DelUser" CommandArgument='<%# Eval("UserID").ToString() %>' ID="imgDelete" runat="server" ImageUrl="~/images/delete_icon.gif" AlternateText="Delete" ToolTip="Delete" />


首先从事件中检索行索引
然后分配给rowindex

First retrieve the row index from the event
and then assign to rowindex

string ID = grd.Rows[rowindex].cells[cellcount].Text;



如果它是模板字段,则



if it is a template field then

string ID = ((Label)grd.Rows[rowindex].FindControl("lblID")).Text;



通过这种方式,您可以检索单元格值...



By this way you can retrieve the cell values...


这篇关于Gridview:如何获取选定的行单元格值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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