我記得有這樣一個問題所困擾之前,我可以用缺乏幫助那裏的話題同情,所以如果你想要一個gridview,這是你如何能做到這一點:
的OnRowDataBound事件添加到你的GridView:
OnRowDataBound="grv_RowDataBound"
添加像這樣到後面的代碼:
private DateTime currentDate;
private int extraCount;
protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//assuming the cell with index 5 is the cell with the Date in it
if (currentDate != DateTime.Parse(e.Row.Cells[5].Text))
{
//making a header row (so it looks different to the other rows)
var row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
var headerCell = new TableHeaderCell();
headerCell.ColumnSpan = 3; //however many columns you have in your gridview
headerCell.Text = e.Row.Cells[5].Text;
row.Cells.Add(headerCell);
currentDate = DateTime.Parse(e.Row.Cells[5].Text);
extraCount++;
grvMortgages.Controls[0].Controls.AddAt(e.Row.RowIndex + extraCount, row);
}
}
}
所以我會更好使用下面的選項,而不是利用像Telerik的一些框架? – 2010-04-07 04:04:57