【发布时间】:2020-04-05 04:57:15
【问题描述】:
我正在研究一个网格视图,并使用 C# 向网格视图动态添加一些行。但是在我执行grd.Rows.Count 时的代码中,它只显示正常行数。
以下是我添加行的代码:
GridViewRow row = new GridViewRow(e.Row.RowIndex + descriptionRowIndex, e.Row.RowIndex + descriptionRowIndex, DataControlRowType.DataRow, DataControlRowState.Insert);
row_index = grdFileUpload1.Rows.Count + descriptionRowIndex;
// Adding Group Expand Collapse Cell
TableCell cell = new TableCell();
// Adding Header Cell
cell = new TableCell();
cell.HorizontalAlign = HorizontalAlign.Left;
cell.Text = "File Description";
cell.Font.Bold = true;
cell.ColumnSpan = 1;
cell.CssClass = "";
row.Cells.Add(cell);
// Adding Description Column
cell = new TableCell();
Label lblfile_desc = new Label();
cell.Controls.Add(lblfile_desc);//file_description.Value;
cell.Text = Session["file_description"].ToString();
cell.HorizontalAlign = HorizontalAlign.Right;
cell.ColumnSpan = 3;
cell.CssClass = "";
row.Cells.Add(cell);
row.ID = "collapsedRow" + row_index;
row.Attributes.Add("Style", "Display:none");
grdFileUpload1.Controls[0].Controls.AddAt(row_index, row);
感谢您的帮助。
【问题讨论】: