你考虑过使用
DataKeyNames
GridView的属性?这样就可以从
GridView
bu仍然访问页面加载中的“id”值。
DataKeyNames = "id"
然后你可以这样得到ID的值。
int selRowIndex = GridView1.SelectedIndex;
int selMasterId = Convert.ToInt32(GridView.DataKeys[selRowIndex].Value);
Order master = Order.Get(selMasterId);
或者,您可以尝试更改
OnRowBound
事件
GRIDVIEW
.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header ||
e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Visible = false;
}
}