 |
|
asp.net ทำอย่างไรให้ gridview แบ่งได้ตามในภาพอ่ะครับช่วยทีครับ |
|
 |
|
|
 |
 |
|
ลองแบบนี้ดูครับ
Code (VB.NET)
Protected Sub GridView_Merge_Header_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
Dim oGridView As GridView = DirectCast(sender, GridView)
Dim oGridViewRow As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
Dim oTableCell As New TableCell()
oGridViewRow.Cells.Add(oTableCell)
oTableCell = New TableCell()
oTableCell.Text = ""
oTableCell.HorizontalAlign = HorizontalAlign.Center
oTableCell.ColumnSpan = 1
oGridViewRow.Cells.Add(oTableCell)
oTableCell = New TableCell()
oTableCell.Text = ""
oTableCell.HorizontalAlign = HorizontalAlign.Center
oTableCell.ColumnSpan = 1
oGridViewRow.Cells.Add(oTableCell)
oTableCell = New TableCell()
oTableCell.Text = "Advan-Re-Imbrusment"
oTableCell.HorizontalAlign = HorizontalAlign.Center
oTableCell.ColumnSpan = 5
oGridViewRow.Cells.Add(oTableCell)
oTableCell = New TableCell()
oTableCell.Text = ""
oTableCell.HorizontalAlign = HorizontalAlign.Center
oTableCell.ColumnSpan = 1
oGridViewRow.Cells.Add(oTableCell)
oGridView.Controls(0).Controls.AddAt(0, oGridViewRow)
End If
End Sub
|
 |
 |
 |
 |
Date :
2013-05-30 11:53:14 |
By :
Maggi123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้า Column แบบแปลก ๆ ก็ลองใช้ Repeater กับ HTML ครับ 
|
 |
 |
 |
 |
Date :
2013-05-30 12:33:28 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ Maggi14 ถ้าเป็น c#ต้องปรับยังไงครับช่วยทีครับ
|
 |
 |
 |
 |
Date :
2013-05-30 14:20:20 |
By :
nananarak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
protected void GridView_Merge_Header_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header) {
GridView oGridView = (GridView)sender;
GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
TableCell oTableCell = new TableCell();
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.Text = "";
oTableCell.HorizontalAlign = HorizontalAlign.Center;
oTableCell.ColumnSpan = 1;
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.Text = "";
oTableCell.HorizontalAlign = HorizontalAlign.Center;
oTableCell.ColumnSpan = 1;
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.Text = "Advan-Re-Imbrusment";
oTableCell.HorizontalAlign = HorizontalAlign.Center;
oTableCell.ColumnSpan = 5;
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.Text = "";
oTableCell.HorizontalAlign = HorizontalAlign.Center;
oTableCell.ColumnSpan = 1;
oGridViewRow.Cells.Add(oTableCell);
oGridView.Controls(0).Controls.AddAt(0, oGridViewRow);
}
}
|
 |
 |
 |
 |
Date :
2013-05-30 17:17:54 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆเลยครับ
|
 |
 |
 |
 |
Date :
2013-05-31 10:14:19 |
By :
nananarak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|