我根据 RowDataBound 事件当前绑定的 Row 在后面的代码上动态添加行。我希望添加的行与当前有界行的状态(备用或正常)相同,这可能吗?
我正在做这样的事情,但它不符合我想要的。我希望动态添加的行与当前行相同。但事实并非如此。
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
GVData data = e.Row.DataItem as GVData; // not original object just for brevity
if(data.AddHiddenRow)
{
// the row state here should be the same as the current
GridViewRow tr = new GridViewRow(e.Row.RowIndex +1, e.Row.RowIndex + 1, DataControlRowType.DataRow, e.Row.RowState);
TableCell newTableCell = new TableCell();
newTableCell.Style.Add("display", "none");
tr.Cells.Add(newTableCell);
((Table)e.Row.Parent).Rows.Add(tr);
}
}
}