我正在使用gridview
with viewstate
。
在这里我想更新gridview
行。gridview
包含 4 列的
插入和删除过程已完成。但我不知道如何用视图状态更新行。谁能帮我??
if (ViewState["PdataTable"] == null)
{
TempDTable.Columns.Add("QuestionID", typeof(string));
TempDTable.Columns.Add("ColumnName", typeof(string));
TempDTable.Columns.Add("ColumnType", typeof(string));
TempDTable.Columns.Add("OptionValues", typeof(string));
}
else
{
TempDTable = (DataTable)ViewState["PdataTable"];
}
DataRow row;
row = TempDTable.NewRow();
TextBox txtftrColName = (TextBox)GridViewColumns.FooterRow.FindControl("txtftrColName");
DropDownList DrpType = (DropDownList)GridViewColumns.FooterRow.FindControl("DrpType");
TextBox txtValues = (TextBox)GridViewColumns.FooterRow.FindControl("txtValues");
row["QuestionID"] = Qst3.Text;
row["ColumnName"] = txtftrColName.Text;
row["ColumnType"] = DrpType.SelectedItem.Text;
row["OptionValues"] = txtValues.Text;
TempDTable.Rows.Add(row);
ViewState["PdataTable"] = TempDTable;
this.GridViewColumns.Visible = true;
GridViewColumns.DataSource = TempDTable;
GridViewColumns.DataBind();