如何获取datarow列值ongridviewrowdatabound [英] How to get datarow column value ongridviewrowdatabound
本文介绍了如何获取datarow列值ongridviewrowdatabound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的数据表中添加了一列
I have added a column to my datatable
dt.Columns.Add("Date")
并将此数据表分配给我的gridview ie
and assigned this datatable to my gridview i.e
grddates.DataSource = dt;
Session.Add("dt", dt);
grddates.DataBind();
现在我想在GridviewRowDataBound上获得该标签的价值。
我怎么样可以做到吗?
有没有其他方法可以做到这一点?
我尝试了什么:
Now I want to get the value of that label on GridviewRowDataBound.
How I can do that?
Is there any other way of doing this?
What I have tried:
I have added a column to my datatable <pre>dt.Columns.Add("Date")
并将此数据表分配给我的gridview即
and assigned this datatable to my gridview i.e
grddates.DataSource = dt;
Session.Add("dt", dt);
grddates.DataBind();
现在我想在GridviewRowDataBound上获得该标签的价值。
我怎么样可以做到吗?
有没有其他方法可以做到这一点?
Now I want to get the value of that label on GridviewRowDataBound.
How I can do that?
Is there any other way of doing this?
推荐答案
if(e.Row.RowType == DataControlRowType.DataRow)
{
int coulumnIndex = 0;
var value= e.Row.Cells[1].Text ;// for reading bound field columns
var value1 = (e.Row.FindControl("label1") as Label).Text;// for reading template columns
}
这篇关于如何获取datarow列值ongridviewrowdatabound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文