Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem in gridview

problem in gridview

Scheduled Pinned Locked Moved ASP.NET
helpquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Spadez
    wrote on last edited by
    #1

    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 ?

    B P A 3 Replies Last reply
    0
    • A Amit Spadez

      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 ?

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Bind your gridview on every postback

      Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

      P A 2 Replies Last reply
      0
      • B Brij

        Bind your gridview on every postback

        Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

        P Offline
        P Offline
        PSK_
        wrote on last edited by
        #3

        I think if EnableViewState="true" for the Grid and Page then its not required to bind the grid in every postback.

        WWW, WCF, WWF, WPF, WFC .... WTF

        1 Reply Last reply
        0
        • A Amit Spadez

          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 ?

          P Offline
          P Offline
          PSK_
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • A Amit Spadez

            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 ?

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            Can you please show us the code ?

            Cheers ! Abhijit Codeproject MVP

            A 1 Reply Last reply
            0
            • A Abhijit Jana

              Can you please show us the code ?

              Cheers ! Abhijit Codeproject MVP

              A Offline
              A Offline
              Amit Spadez
              wrote on last edited by
              #6

              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 Reply Last reply
              0
              • P PSK_

                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

                A Offline
                A Offline
                Amit Spadez
                wrote on last edited by
                #7

                I have checked all three points you have sent.But still it doesn't work

                1 Reply Last reply
                0
                • B Brij

                  Bind your gridview on every postback

                  Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

                  A Offline
                  A Offline
                  Amit Spadez
                  wrote on last edited by
                  #8

                  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); } }

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups