protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Table table = (Table)this.GridView1.Controls[0];
int realIndex = table.Rows.GetRowIndex(e.Row);
GridView oGridView = (GridView)sender;
GridViewRow oGridViewRow = new GridViewRow(realIndex, realIndex, DataControlRowType.Separator, DataControlRowState.Normal);
TableCell oTableCell = new TableCell();
oGridViewRow.Cells.Add(oTableCell);
table.Controls.AddAt(realIndex, oGridViewRow);
}
}
本文介绍了一个ASP.NET中GridView控件RowCreated事件的处理方法。通过该事件可以实现在GridView的每一行创建时进行自定义操作,例如添加额外的行或单元格。文章详细展示了如何获取当前行的实际索引,并在表格中插入新的分隔符行。

6536

被折叠的 条评论
为什么被折叠?



