如何获取单元格的值指定GridView ASP.NET [英] How to get the value of a cell specifies the GridView ASP.NET
本文介绍了如何获取单元格的值指定GridView ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取GridView单元格的值.当用户单击网格时,我需要知道哪个行按钮,然后获取单元格的值.我正在尝试使用以下代码,但无法正常工作.
I need to get the value of a cell of a GridView. When the user click on the grid, I need to know which line button, and then get the value of the cell. I'm trying to use the following code, but not work.
protected void gvSearch_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
int row = Convert.ToInt32(e.CommandArgument);
string tst = gvSearch.Rows[row].Cells[1].Text;
}
}
我不知道我是否在使用正确的事件来实现自己的目标.如果有人可以帮助我,我谢谢你.
I do not know if I'm using the right event to get on my goal. If someone can help me, I thank you.
推荐答案
我找到了解决方案!
我正在使用BoundField.
Am using BoundField.
<asp:BoundField HeaderText="Código Área" DataField=" <asp:BoundField HeaderText="Denominação Área" DataField="areaName" />
protected void gvSearch_SelectedIndexChanged(object sender, EventArgs e)
{
String lastName = gvSearch.SelectedRow.Cells[1].Text;
}
谢谢大家!
这篇关于如何获取单元格的值指定GridView ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文