Last post Dec 10, 2013 10:09 PM by KumarHarsh
Dec 09, 2013 11:25 AM|linlin|LINK
How to persists gridview textbox value when paging.
My situation is after user entered text in textbox they will click on the button to check their answer. But after i click gridview next page the previous page textbox value is not keep.
Dec 09, 2013 12:13 PM|l.laxmikant|LINK
You will have to manage it using viewstate variables. As clicking on next page you must be refreshing values of Gridview for new page details.
So when you change the page index save your textbox details to ViewState varibale and when you come back check if the ViewState variable has value
Dec 10, 2013 04:19 AM|linlin|LINK
I have save the viewstate when button click and display the viewstate value in label text and textbox. But the textbox value is still missing.
ViewState["ID"] = txt.Text; ->button click
protected void Page_Load(object sender, EventArgs e)
if (ViewState["ID"] != null)
TextBox txt1 = (TextBox)GridView1.Rows.FindControl("TextBox1");
Label1.Text = ViewState["ID"].ToString();
foreach (GridViewRow row in GridView1.Rows)
txt1.Text = ViewState["ID"].ToString();
Dec 10, 2013 10:09 PM|KumarHarsh|LINK
Is the gridview editable ? I think in viewstate you hv to store few thing.
i) row number of grid which was click.
iii)boolean to indicate if griview edit was click.
you can call this function in page index change itself .