c# - MultiView and GridView Paging issue -


i have multi view 2 views in it. view1 has grid view , grid-view allow paging ten records.

the problem have press page number tow times go page.

the first click nothing happen second click grid view goes page issue

<asp:gridview id="gridusers" autogeneratecolumns="false" runat="server" allowpaging="true" onpageindexchanging="onpageindexchanging" pagesize="10" cssclass="table table-bordered text-nowrap" onselectedindexchanged="gridusers_selectedindexchanged"  onrowdeleting="gridusers_rowdeleting">                        <columns>                          <asp:templatefield headertext="edit">                              <itemtemplate>                                   <asp:linkbutton id="linkbutton1" runat="server" cssclass="btn btn-primary btn-xs" causesvalidation="false"  commandname="select" text="" ><i class="glyphicon glyphicon-pencil"></i></asp:linkbutton>                               </itemtemplate>                              <controlstyle cssclass="btn btn-primary" />                          </asp:templatefield>                          <asp:templatefield headertext="delete">                              <itemtemplate>                                  <asp:linkbutton id="linkbutton2" runat="server" causesvalidation="false"  onclientclick="return confirm('are sure want delete record ?');" cssclass="btn btn-primary btn-xs" commandname="delete" text="delete"><i class="glyphicon glyphicon-trash"></i></asp:linkbutton>                              </itemtemplate>                              <controlstyle cssclass="btn btn-danger" />                          </asp:templatefield>                          <asp:boundfield datafield="id" headertext="customer id" sortexpression="customer id" />                          <asp:boundfield datafield="name" headertext="customer name" sortexpression="name" />                          <asp:boundfield datafield="contact person" headertext="contact person" sortexpression="contact person" />                          <asp:boundfield datafield="p.o.box" headertext="p.o.box" sortexpression="p.o.box" />                          <asp:boundfield datafield="address" htmlencodeformatstring="false" headertext="address" sortexpression="address" />                          <asp:boundfield datafield="mobile no" headertext="mobile no" sortexpression="mobile no" />                       </columns>                 <selectedrowstyle backcolor="#d1ddf1"  forecolor="#333333" />                </asp:gridview>   protected void page_load(object sender, eventargs e)     {         customerclass c = new customerclass();          if (!this.ispostback)         {             gridusers.datasource = c.getcst();             gridusers.databind();         }     }    protected void onpageindexchanging(object sender, gridviewpageeventargs e)     {         gridusers.pageindex = e.newpageindex;         this.c.getcst();     } 

you not rebinding grid once page number changes.

your code this:

protected void onpageindexchanging(object sender, gridviewpageeventargs e) {     gridusers.pageindex = e.newpageindex;     this.c.getcst(); } 

you need instead:

protected void onpageindexchanging(object sender, gridviewpageeventargs e) {     gridusers.pageindex = e.newpageindex;     gridusers.datasource = c.getcst();     gridusers.databind(); } 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -