get header for the cell
i have this
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Style.Add("text-align", "center");
}
i want to make the header of this cell invisible.. how can i do this by just knowing the cell value...
it does not find the header... i am crea开发者_如何学Cting the header at runtime... like this
GridView Grid = new GridView();
Grid.RowDataBound += Grid_RowDataBound;
Grid.ID = machGrps[j].ToString();
//Grid.AutoGenerateColumns = false;
Grid.AllowSorting = false;
Grid.CellSpacing = 2;
Grid.ForeColor = System.Drawing.Color.White;
Grid.GridLines = GridLines.None;
Grid.Width = Unit.Percentage(100);
Grid.Style.Add(HtmlTextWriterStyle.Overflow, "Scroll");
Grid.ShowHeader = true;
DataTable taskTable = new DataTable("TaskList7");
taskTable.Columns.Add("MachineID");
DataRow tableRow = taskTable.NewRow();
tableRow["MachineID"] = machID[i];
taskTable.Rows.Add(tableRow);
Grid.DataSource = taskTable;
Grid.DataBind();
protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false;
}
}
Sorry for VB.Net :
Select Case e.Row.RowType
Case DataControlRowType.Header
e.Row.Cells(0).Visible = False
End Select
Edit: C#
if (e.Row.RowType == DataControlRowType.Header){
e.Row.Cells(0).Visible = False;
}
精彩评论