62,243
社区成员




protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Header)
{
//e.Row.Cells[这个值怎么根据字段名得到].Visible = false; //
//e.Row.Cells[
//e.Row.Cells
//TableRow
//TableCellCollection
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[13].Attributes.Add("style", "display:none;");
e.Row.Cells[14].Attributes.Add("style", "display:none;");
e.Row.Cells[15].Attributes.Add("style", "display:none;");
e.Row.Cells[16].Attributes.Add("style", "display:none;");
e.Row.Cells[17].Attributes.Add("style", "display:none;");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[5].Visible = false;
}
if (e.Row.Cells[i].Text = "特定列名")
if (e.Row.Cells[i].Text == "特定列名")
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
int index = -1;
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
// 不是字段名,是字段对应的列的列名
if (e.Row.Cells[i].Text = "特定列名")
{
e.Row.Cells[i].Visible = false;
index = i;
}
}
}
else if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (i == index)
{
e.Row.Cells[i].Visible = false;
}
}
}
}