c# - gridview sort order changes when editing row -


i have gridview displays records based on filter dropdownlist, when change dropdownlist page postbacks fine , filter works, when click edit row sort order changes based on new filter. when change drop down original filter , click edit sort order remains same.

any ideas?

<asp:dropdownlist id="ddlfilterdocs" runat="server"                       autopostback="true"                       onselectedindexchanged="ddlfilterdocs_selectedindexchanged">                                       <asp:listitem text="missingdata"  value="missingdata" >missingdata</asp:listitem>                                        <asp:listitem text="alldata" value="alldata"  >alldata</asp:listitem>            </asp:dropdownlist>    <asp:gridview id="gridview1" runat="server" allowpaging="true"                   allowsorting="true" pagesize="35"                   autogeneratecolumns="false" cellpadding="4"                   forecolor="#333333" gridlines="none"                   onrowcommand="gridview1_rowcommand" datakeynames="customercode"                   onpageindexchanging="gridview1_pageindexchanging"                   onsorting="gridview1_sorting">                  <alternatingrowstyle backcolor="white" />                  <columns>                        <asp:templatefield sortexpression="customercode">                          <itemtemplate>                             <asp:linkbutton id="lbedit" forecolor="darkgreen" font-    bold="true" commandargument='<%# eval("customercode") %>' commandname="editrow"  runat="server">edit</asp:linkbutton>                            </itemtemplate>                          <edititemtemplate>                                      <asp:linkbutton id="lbupdate" commandargument='<%#  eval("customercode") %>' commandname="updaterow" runat="server"   forecolor="white">update</asp:linkbutton>                              <asp:linkbutton id="lblcancel" commandargument='<%#  eval("customercode") %>' commandname="cancelupdate" runat="server"   forecolor="white">cancel</asp:linkbutton>                           </edititemtemplate>                            <headerstyle width="100px" />                      </asp:templatefield>                       <asp:templatefield  headertext="customer id"  sortexpression="customercode">                          <edititemtemplate>                              <asp:label id="lblcustcodeedit" runat="server" text='<%#  eval("customercode") %>'></asp:label>                          </edititemtemplate>                          <itemtemplate>                              <asp:label id="lblcustcode" runat="server" text='<%#  bind("customercode") %>'></asp:label>                          </itemtemplate>                      </asp:templatefield>                      <asp:boundfield  datafield="name" headertext="name"  sortexpression="name"                             readonly="true" >                        <headerstyle width="100px" />                        </asp:boundfield>                      <asp:templatefield headertext="streetaddress"  sortexpression="streetaddress">                          <edititemtemplate>                              <asp:textbox id="tbxstreetaddress" runat="server"  text='<%# bind("streetaddress") %>'></asp:textbox>                          </edititemtemplate>                          <itemtemplate>                              <asp:label id="lblstreetaddress" runat="server" text='<%#  bind("streetaddress") %>'></asp:label>                          </itemtemplate>                          <headerstyle width="150px" />                      </asp:templatefield>                      <asp:templatefield headertext="city" sortexpression="city">                          <edititemtemplate>                              <asp:textbox id="tbxcity" runat="server" text='<%#  bind("city") %>'></asp:textbox>                          </edititemtemplate>                          <itemtemplate>                              <asp:label id="lblcity" runat="server" text='<%#  bind("city") %>'></asp:label>                          </itemtemplate>                          <headerstyle width="100px" />                      </asp:templatefield>                      <asp:templatefield headertext="zip" sortexpression="zip">                          <edititemtemplate>                              <asp:textbox id="tbxzip" runat="server" text='<%#  bind("zip") %>'></asp:textbox>                          </edititemtemplate>                          <itemtemplate>                              <asp:label id="lblzip" runat="server" text='<%#  bind("zip") %>'></asp:label>                          </itemtemplate>                          <headerstyle width="50px" />                      </asp:templatefield>                      <asp:boundfield datafield="docnumber" headertext="docnumber"                           sortexpression="docnumber" readonly="true">                        <headerstyle width="50px" />                        </asp:boundfield>                      <asp:boundfield datafield="grossamount" headertext="gross"                           sortexpression="grossamount"  readonly="true"  dataformatstring="{0:c2}"  >                        <headerstyle width="70px" />                        </asp:boundfield>                      <asp:boundfield datafield="netamount" headertext="net"                           sortexpression="netamount"  readonly="true" dataformatstring=" {0:c2}" >                        <headerstyle width="70px" />                        </asp:boundfield>                      <asp:boundfield datafield="vatamount" headertext="vat"                           sortexpression="vatamount"  readonly="true" dataformatstring=" {0:c2}" >                        <headerstyle width="70px" />                        </asp:boundfield>                      <asp:boundfield datafield="fromvoucnbr" headertext="voucher"                           sortexpression="fromvoucnbr"  readonly="true" >                        <headerstyle width="70px" />                        </asp:boundfield>                      <asp:boundfield datafield="lastmoddate" headertext="date"                           sortexpression="lastmoddate"  readonly="true"  dataformatstring="{0:g}" >                        <headerstyle width="70px" />                        </asp:boundfield>                      <asp:boundfield datafield="lastmoduser" headertext="lastmoduser"                           sortexpression="lastmoduser"   readonly="true">                        <headerstyle width="50px" />                        </asp:boundfield>                  </columns>                  <editrowstyle backcolor="#7c6f57" />                  <footerstyle backcolor="#1c5e55" font-bold="true" forecolor="white" />                  <headerstyle backcolor="#1c5e55" font-bold="true" forecolor="white" />                  <pagerstyle backcolor="#666666" forecolor="white"  horizontalalign="center" />                  <rowstyle backcolor="#e3eaeb" />                  <selectedrowstyle backcolor="#c5bbaf" font-bold="true"  forecolor="#333333" />                  <sortedascendingcellstyle backcolor="#f8fafa" />                  <sortedascendingheaderstyle backcolor="#246b61" />                  <sorteddescendingcellstyle backcolor="#d4dfe1" />                  <sorteddescendingheaderstyle backcolor="#15524a" />              </asp:gridview> 

if rebinding data row_editing event need filter drop down selected value.

regards,


Comments