您的位置:首页 > 其它

GridView中如何取隐藏列的值

2010-10-20 13:33 197 查看
GridView中如果有隐藏列的话,通过这种方式值取不到值的:

this.GridView.Rows[e.NewEditIndex].Cells[2].Text

所以必须通过其他的方式来取值:

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)

{

//如果DataKeyNames有多个值(DataKeyNames="ID,ProjectState,PriceState")

//可以通过以下方式来取值

this.GridView_Price.DataKeys[e.Row.RowIndex].Values[0].ToString();

this.GridView_Price.DataKeys[e.Row.RowIndex].Values[1].ToString();

this.GridView_Price.DataKeys[e.Row.RowIndex].Values[2].ToString();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: