|
|
|
จะทำ gridview ยังไงให้ได้แบบนี้ลองทำหลายอย่างแล้วทำไม่ได้ซักที |
|
|
|
|
|
|
|
ทำพวกใน FindControl ครับ อยากจะกำหนดแบบไหนก็ได้ครับ หรือไม่เปลี่ยนไปใช้ Repeater ดูครับ จะง่ายกว่าเดิมครับ
|
|
|
|
|
Date :
2012-07-26 13:32:58 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โม header ด้วย event RowCreated
ประมาณว่า remove header เก่าทิ้ง
แล้วสร้าง row header ขึ้นมาใหม่ โดยกำหนด rolspan หรือ colspan เอง
Code (C#)
GridView1.RowCreated += new GridViewRowEventHandler(GridView1_RowCreated);
Code (C#)
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView Gv = sender as GridView;
e.Row.Cells.Clear();
TableCell Cell1 = new TableCell();
Cell1.RowSpan = 2;
Cell1.Text = "#";
Cell1.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell1.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
TableCell Cell2 = new TableCell();
Cell2.RowSpan = 2;
Cell2.Text = "Month Name";
Cell2.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell2.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
TableCell Cell3 = new TableCell();
Cell3.ColumnSpan = 3;
Cell3.Text = "Tungman";
Cell3.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell3.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
TableCell Cell4 = new TableCell();
Cell4.RowSpan = 2;
Cell4.Text = "Delete";
Cell4.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell4.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
GridViewRow Gvr1 = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
Gvr1.Cells.Add(Cell1);
Gvr1.Cells.Add(Cell2);
Gvr1.Cells.Add(Cell3);
Gvr1.Cells.Add(Cell4);
TableCell Cell5 = new TableCell();
Cell5.Text = "Sub #1";
Cell5.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell5.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
TableCell Cell6 = new TableCell();
Cell6.Text = "Sub #2";
Cell6.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell6.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
TableCell Cell7 = new TableCell();
Cell7.Text = "Sub #3";
Cell7.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
Cell7.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
GridViewRow Gvr2 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
Gvr2.Cells.Add(Cell5);
Gvr2.Cells.Add(Cell6);
Gvr2.Cells.Add(Cell7);
Gv.Controls[0].Controls.AddAt(0, Gvr1);
Gv.Controls[0].Controls.AddAt(1, Gvr2);
}
}
|
|
|
|
|
Date :
2012-07-26 13:55:13 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|