DataGrid中隐藏列,但可以让其它列得到资料,方法为在ItemDataBound事件中增加下边方法。代码如下:
/// <summary>
/// 隐藏列表,便于系统读取隐藏列资料
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GrdValue_ItemDataBound(object sender, DataGridItemEventArgs e)
e.Item.Cells[2].Style["Display"] = "None";
e.Item.Cells[4].Style["Display"] = "None";
}
/// 隐藏列表,便于系统读取隐藏列资料
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GrdValue_ItemDataBound(object sender, DataGridItemEventArgs e)
{
//隐藏第一列表
e.Item.Cells[0].Style["Display"] = "None";e.Item.Cells[2].Style["Display"] = "None";
e.Item.Cells[4].Style["Display"] = "None";
}