Click here to Skip to main content
16,021,169 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Haiiii
I have 4 rows in GridView, each row having 9 columns, GridView is maintained in Viewstate. In GridView row two columns are TextBox-fields.

When i change the TextBox-field then three coumns are reflected in GridView. So, i need to know how to store these columns in Viewstate instead of row. Please tell me how to do.

Thanks in advance
Posted

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();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900