problem in gridview
-
hello all, i have made a project.In one page, After page is postback, GridView "grd1" bound with some values. After another postback,it lost its data. I have used EnableViewState="true" in gridview control but still it doesn't work. could u help me ?
-
hello all, i have made a project.In one page, After page is postback, GridView "grd1" bound with some values. After another postback,it lost its data. I have used EnableViewState="true" in gridview control but still it doesn't work. could u help me ?
Bind your gridview on every postback
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
Bind your gridview on every postback
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
hello all, i have made a project.In one page, After page is postback, GridView "grd1" bound with some values. After another postback,it lost its data. I have used EnableViewState="true" in gridview control but still it doesn't work. could u help me ?
1- Check that the EnableViewState property is not false for the entire page. 2- EnableViewState is not set as false in the web.config file. 3- You are not explicitly setting the gridview Datasoure as null in your postback code.
WWW, WCF, WWF, WPF, WFC .... WTF
-
hello all, i have made a project.In one page, After page is postback, GridView "grd1" bound with some values. After another postback,it lost its data. I have used EnableViewState="true" in gridview control but still it doesn't work. could u help me ?
Can you please show us the code ?
Cheers ! Abhijit Codeproject MVP
-
Can you please show us the code ?
Cheers ! Abhijit Codeproject MVP
I'm sending you the code.In this, when we refresh the page, "gvQA.Rows.Count" shows 0 rows. Here's code: protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { gvQA.DataSource = null; gvQA.DataBind(); BindQues(); } } #region Methods public void BindQues() { try { if (Session["BindData"] == null) { ds = new DataSet(); ds = objGet.GetData(Request["JT"].ToString()); litMsg.Text = "Online Test"; if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { gvQA.Visible = true; gvQA.DataSource = ds; gvQA.DataBind(); Session["BindData"] = ds; } else { gvQA.Visible = false; } } } else { ds =(DataSet)Session["BindData"]; gvQA.Visible = true; gvQA.DataSource = ds; gvQA.DataBind(); } } catch (Exception ex) { Response.Write(ex.Message); } }
-
1- Check that the EnableViewState property is not false for the entire page. 2- EnableViewState is not set as false in the web.config file. 3- You are not explicitly setting the gridview Datasoure as null in your postback code.
WWW, WCF, WWF, WPF, WFC .... WTF
I have checked all three points you have sent.But still it doesn't work
-
Bind your gridview on every postback
Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators
I have already done that. But still problem occurs....... protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { BindQues(); } } #region Methods public void BindQues() { try { if (Session["BindData"] == null) { ds = new DataSet(); ds = objGet.GetData(Request["JT"].ToString()); litMsg.Text = "Online Test"; if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { gvQA.Visible = true; gvQA.DataSource = ds; gvQA.DataBind(); Session["BindData"] = ds; } else { gvQA.Visible = false; } } } else { ds =(DataSet)Session["BindData"]; gvQA.Visible = true; gvQA.DataSource = ds; gvQA.DataBind(); } } catch (Exception ex) { Response.Write(ex.Message); } }