title: Is it possible to prevent postback when changing the GridView Paging Index?
body: <p>I am trying to create my own online quiz website using ASP C#.</p>
  
  <p>I tried to bind the question from database into <code>gridview</code> and set the page size of the <code>gridview</code> to 1.
  And then I tried to pull the answers option (4 option) into <code>radioButton</code>.</p>
  
  <p>But when I tried to move from the 1 page of <code>gridview</code> to another page, the checked value lost. I know thats because of when we changed the <code>gridview</code> page, it will do a <code>postback</code>.</p>
  
  <p>My Questions are:</p>
  
  <ol>
  <li>Why I can't access my <code>RadioButton</code> from CodeBehind? Is it because of inside the Updatepanel ?</li>
  <li>Is it possible if we want to do a page index change in gridview without <code>postback</code>? Or,</li>
  <li>is there another option to make my <code>RadioButton</code> checked value not lost when changing to the next page (next question) ?</li>
  </ol>
  
  <p>here are my code :</p>
  
  <p><strong><code>**</code>quiz.aspx :<code>**</code></strong></p>
  
  <pre><code>&lt;asp:UpdatePanel ID="upd1" runat="server"&gt;
      &lt;ContentTemplate&gt;
          &lt;asp:GridView ID="grdquestions" runat="server" EnableViewState="true" EnableSortingAndPagingCallbacks="false" OnPageIndexChanging="grdquestions_PageIndexChanging" AutoGenerateColumns="false" DataKeyNames="QuestionId" Width="100%" AllowPaging="True" AllowCustomPaging="False" PageSize="1" ViewStateMode="Enabled"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField HeaderText="DOJO eQuiz"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;table class="tableclass" id='&lt;%#Eval("QuestionId") %&gt;'&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;&lt;b&gt;Question : &lt;%#Eval("Question") %&gt;&lt;/b&gt;
                                      &lt;asp:HiddenField ID="hdnquestionId" runat="server" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;
                                      &lt;table&gt;
  
                                          &lt;tr style="margin-top: 10px;"&gt;
  
                                              &lt;td&gt;
                                                  &lt;table class="tblOptions"&gt;
                                                      &lt;tr&gt;
                                                          &lt;td&gt;
                                                              &lt;asp:RadioButton ID="rdOption1" AutoPostBack="true" runat="server" Text='&lt;%#Eval("Option1") %&gt;' GroupName="chcbox" /&gt;
  
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr&gt;
                                                          &lt;td&gt;
                                                              &lt;asp:RadioButton ID="rdOption2" runat="server" AutoPostBack="true" Text='&lt;%#Eval("Option2") %&gt;' GroupName="chcbox" /&gt;
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr&gt;
                                                          &lt;td&gt;
                                                              &lt;asp:RadioButton ID="rdOption3" runat="server" AutoPostBack="true" Text='&lt;%#Eval("Option3") %&gt;' GroupName="chcbox" /&gt;
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr&gt;
                                                          &lt;td&gt;
                                                              &lt;asp:RadioButton ID="rdOption4" runat="server" Text='&lt;%#Eval("Option4") %&gt;' GroupName="chcbox" /&gt;
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr&gt;
                                                          &lt;td&gt;
                                                              &lt;asp:Label ID="lbquestionstatus" runat="server"&gt;&lt;/asp:Label&gt;
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
  
                                                  &lt;/table&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                      &lt;/table&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
  
                          &lt;/table&gt;
  
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
              &lt;PagerStyle HorizontalAlign="Center" CssClass="GridPager" /&gt;
          &lt;/asp:GridView&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p><strong><code>**</code>quiz.aspx.cs<code>**</code></strong></p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          if (Session["username"] == null)
          {
              Response.Redirect("Login.aspx");
  
          }
          else
          {
              if (!Page.IsPostBack)
              {
                  BindGrid();
  
              }
              else
              {
              }
          } 
      }
  
  
   public void BindGrid()
      {
          var sess = Session["username"].ToString();
          string a = sess.Substring(sess.Length - 1);
  
          SqlDataAdapter adp = new SqlDataAdapter("select * from dojoquiz order by " + a + "", ConfigurationManager.ConnectionStrings["dashboardConnectionString"].ToString());
          adp.Fill(dt);
  
          grdquestions.DataSource = dt;
          grdquestions.DataBind();
      }
  
  protected void grdquestions_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              RadioButtonList rdlstOptions = (RadioButtonList)e.Row.FindControl("rdlstOptions");
              HiddenField hdnquestionId = (HiddenField)e.Row.FindControl("hdnquestionId");
              if (rdlstOptions != null &amp;&amp; hdnquestionId != null)
              {
                  DataRow[] result = dt.Select("questionid=" + (Convert.ToInt32(hdnquestionId.Value)));
                  DataView view = new DataView();
                  view.Table = dt;
                  view.RowFilter = "questionid=" + (Convert.ToInt32(hdnquestionId.Value));
                  if (view.Table.Rows.Count &gt; 0)
                  {
                      DataTable dt1 = new DataTable();
                      dt1 = view.ToTable();
                  }
              }
          }
      }
  
      protected void grdquestions_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          grdquestions.PageIndex = e.NewPageIndex;
          this.BindGrid();
      }
  </code></pre>
  
  <p>Thank you for any help and suggestions.</p>