如何将Gridview数据选择到标签中 [英] How to Select Gridview data into a label
本文介绍了如何将Gridview数据选择到标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码将Gridview数据添加到标签中。
I am Using the following code to get Gridview data into label.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
lblId.Text = row.Cells[0].Text;
lblMarks.Text = row.Cells[1].Text;
}
它的工作正常但是,当我分配这个
It's work good but, when I assign this
GridView1.Columns[0].Visible = false;
然后前面的代码返回null。我怎样才能克服这个问题。
then the previous code return null. How can I overcome this.
推荐答案
我自己解决了它只需将我的gridview属性EnableViewState true转为false
I have solve it myself by Just turn my gridview property EnableViewState true to false
EnableViewState="False"
这篇关于如何将Gridview数据选择到标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文