如何在文本框中检索GridView amd显示的隐藏列值 [英] how to retrieve a hidden column value of GridView amd display in a textbox
本文介绍了如何在文本框中检索GridView amd显示的隐藏列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文本框中检索GridView amd显示的隐藏列值
how to retrieve a hidden column value of GridView amd display in a textbox
推荐答案
在gridview的rowupdating事件中添加以下代码:
On rowupdating event of the gridview add this code:
int id = GridView1.DataKeys(e.RowIndex).Value;
这是获取所选行的ID的示例.您可以执行以下操作将其直接传输到文本框中:
that''s an example of getting the ID of the selected row. You can transfer it directly into a textbox by doing:
txtID.Text = GridView1.DataKeys(e.RowIndex).Value.ToString();
如果您只是通过使用Visible = false隐藏该列,则只需执行以下代码即可.这里的0代表所选行的列索引.
If you are just hiding the column by using Visible=false, just simply do the below code. The 0 here represents the column index of the selected row.
txtID.Text = GridView1.SelectedRow.Cells[0].Text
最好的问候,
爱德华
Best regards,
Eduard
尝试一下
try this
protected void grvItems_SelectedIndexChanged(object sender, EventArgs e)
{
//for example, cells[1] is hidden
txtID.Text = grvItems.SelectedRow.Cells[1].Text;
}
希望对您有帮助,
如果有帮助,请标记为答案
谢谢!
hope it helps,
mark as answer if it helps you
thanks!
您好,Santhosh,
在检索单元格值之前,您可以看到像
这样的单元格值 GVUOM.SelectedRow.Cells [0] .visible = true
字符串val = GVUOM.SelectedRow.Cells [0] .tex;
获得价值后
禁用
GVUOM.SelectedRow.Cells [0] .visible = false;
Hi Santhosh,
before you retrieve a cell value youcan visible cell value like
GVUOM.SelectedRow.Cells[0].visible=true
string val=GVUOM.SelectedRow.Cells[0].tex;
after getting value
disable like
GVUOM.SelectedRow.Cells[0].visible=false;
这篇关于如何在文本框中检索GridView amd显示的隐藏列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文