我有這個得到頭的電池
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Style.Add("text-align", "center");
}
我想使這個細胞無形的頭..我如何通過只知道單元格的值做到這一點...
它找不到頭...我在運行時創建的頭......這樣
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;
}
}
你想使一個單元的頭看不見?還是所有的細胞?我不認爲這是可能的使一個標頭不可見... – MrFox 2010-11-18 22:11:28
一個標題..像單元格[0]隱藏的標題 – user175084 2010-11-18 22:14:05
我可以通過e.Row [0] .Visible = false使單元格不可見; – user175084 2010-11-18 22:15:13