如何检索控件的值,例如gridview itemTemplate中的标签 [英] how to retrieve value of control such as label in gridview itemTemplate
本文介绍了如何检索控件的值,例如gridview itemTemplate中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题.
1)在GridView的itemTemplate中使用标签来显示数据.我想检索标签的值.
2)如何更改检索到它的标签的值并更改它的值,然后显示数据
hi i have problem.
1) in GridView itemTemplate use label to show data . i want to retrieve the value of label .
2) how can i change the value of label that retrieve it and change value of it then show the data
推荐答案
获取值
string strEmployeeID = ((Label)(GridView1.Rows[0].Cells[3].Controls[1])).Text
您可以为该控件分配任何值,就像从该控件获取方法一样.
设置值
You can assign any value to that control as same way get from that control.
Set Value
string strEmployeeID = "EMP001";
((Label)(GridView1.Rows[0].Cells[3].Controls[1])).Text = strEmployeeID
请根据您的要求更改代码.
please change the code based on your requirement.
您好,
请参考下面的代码.
Hi,
Please refer the code below.
string str = ((Label)Rows[0].Cells[1].Controls[0])).Text
string str = "Label1";
(((Label)Rows[0].Cells[1].Controls[0])).Text = str;
这篇关于如何检索控件的值,例如gridview itemTemplate中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文