c# - Two gridview's selected indexchanged event does not work -


i set 2 gridview in 1 page. one's selected index changed event's load event. 2nd grid's selectedindexchanged event goes on first's selectedindexchanged event. can do? function name correct. not conflicting other.

here asp code :

<asp:gridview id="gdv" runat="server"                  autogeneratecolumns="false" onrowdatabound="gdv_rowdatabound"                  onselectedindexchanged="gdv_selectedindexchanged" allowpaging="true"                  width="100%" onpageindexchanging="gdv_pageindexchanging">                 <columns>                     <asp:boundfield datafield="sl" headerstyle-horizontalalign="center"                          headertext="sl #" itemstyle-horizontalalign="center">                     <headerstyle horizontalalign="center" />                     <itemstyle horizontalalign="center" />                     </asp:boundfield>                     <asp:boundfield datafield="salesorderno" headerstyle-horizontalalign="left"                          headertext="order no" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="sectionid" headerstyle-horizontalalign="left"                          headertext="section id" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="sectionname" headerstyle-horizontalalign="left"                          headertext="section name" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="outletid" headerstyle-horizontalalign="left"                          headertext="outlet id" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="outletname" headerstyle-horizontalalign="left"                          headertext="outlet name" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="salespersonid" headerstyle-horizontalalign="left"                          headertext="sales person name" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="orderdate" headerstyle-horizontalalign="left"                          headertext="order date" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="ordervalue" headerstyle-horizontalalign="left"                          headertext="order value" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                    <asp:templatefield headertext="select" headerstyle-horizontalalign="center" itemstyle-horizontalalign="center">                         <itemtemplate>                             <asp:checkbox id="checkorderlist" runat="server" validationgroup="valcheckorder" />                         </itemtemplate>                     </asp:templatefield>                     <asp:templatefield headertext="select" headerstyle-horizontalalign="center" itemstyle-horizontalalign="center">                        <itemtemplate>                     <%--<asp:linkbutton id="btnview" text="view" runat="server" commandname="viewindividualorder" />--%>                      <asp:button id="btnvieworder" runat="server" text="view" validationgroup="valcheckorder"                         commandname="viewindividualorder" onclick="btnvieworder_click" />                 </itemtemplate>                     </asp:templatefield>                  </columns>                 <pagerstyle horizontalalign="center" />             </asp:gridview>  <asp:gridview id="gdvorderdetail" runat="server"                  autogeneratecolumns="false" onrowdatabound="gdvorderdetail_rowdatabound"                  onselectedindexchanged="gdvorderdetail_selectedindexchanged" allowpaging="true"                  width="100%" onpageindexchanging="gdvorderdetail_pageindexchanging">                 <columns>                     <asp:boundfield datafield="sl" headerstyle-horizontalalign="center"                          headertext="sl #" itemstyle-horizontalalign="center">                     <headerstyle horizontalalign="center" />                     <itemstyle horizontalalign="center" />                     </asp:boundfield>                     <asp:boundfield datafield="productid" headerstyle-horizontalalign="left"                          headertext="product id" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="productname" headerstyle-horizontalalign="left"                          headertext="product name" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="unitid" headerstyle-horizontalalign="left"                          headertext="unit" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                     <asp:boundfield datafield="packetsize" headerstyle-horizontalalign="left"                          headertext="packet size" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>                <asp:templatefield headertext="sales rate" itemstyle-horizontalalign="center">                 <itemtemplate>                      <asp:label id="lblsalesrate" runat="server" text='<%# eval("salesrate") %>' font-size="smaller" />                 </itemtemplate>             </asp:templatefield>                    <%-- <asp:boundfield datafield="salesrate" headerstyle-horizontalalign="left"                          headertext="sales rate" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>--%>                     <asp:boundfield datafield="orderqty" headerstyle-horizontalalign="left"                          headertext="order qty" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>               <asp:templatefield headertext="memoqty" itemstyle-horizontalalign="center">                 <itemtemplate>                     <asp:textbox id="txtmemoqty" runat="server" font-bold="true" width="100px" ontextchanged="txtmemoqty_textchanged"                         autopostback="true" enabled="true" onkeypress="return onlynumbers();"></asp:textbox>                     <asp:requiredfieldvalidator id="requiredfieldvalidatormemoqty" validationgroup="valcheckorderdetail"                         runat="server" controltovalidate="txtmemoqty" errormessage="*" font-size="x-large"                         forecolor="red"></asp:requiredfieldvalidator>                 </itemtemplate>             </asp:templatefield>              <asp:templatefield headertext="amount" itemstyle-horizontalalign="center">                 <itemtemplate>                      <asp:label id="lblamount" runat="server" text='<%# eval("amount") %>' font-size="smaller" />                 </itemtemplate>             </asp:templatefield>                     <%--<asp:boundfield datafield="amount" headerstyle-horizontalalign="left"                          headertext="amount" itemstyle-horizontalalign="left">                     <headerstyle horizontalalign="left" />                     <itemstyle horizontalalign="left" />                     </asp:boundfield>--%>                    <asp:templatefield headertext="select" headerstyle-horizontalalign="center" itemstyle-horizontalalign="center">                         <itemtemplate>                             <asp:checkbox id="checkorderlist" runat="server" validationgroup="valcheckorderdetail" />                         </itemtemplate>                     </asp:templatefield>                   </columns>                 <pagerstyle horizontalalign="center" />             </asp:gridview> 

c# code:

protected void gdv_selectedindexchanged(object sender, eventargs e) {     int indx = 0;     indx = gdv.selectedindex;      string salesorderno = "";     string sectionid = "";     string sectionname = "";     string outletid = "";     string outletname = "";     string salespersonname = "";     string orderdate = "";     string ordervalue = "";     string ordercheck = "";      (int = 0; < 1; i++)     {         salesorderno = gdv.rows[indx].cells[1].text.tostring();         sectionid = gdv.rows[indx].cells[2].text.tostring();         sectionname = gdv.rows[indx].cells[3].text.tostring();         outletid = gdv.rows[indx].cells[4].text.tostring();         outletname = gdv.rows[indx].cells[5].text.tostring();         salespersonname = gdv.rows[indx].cells[6].text.tostring();         orderdate = gdv.rows[indx].cells[7].text.tostring();         ordervalue = gdv.rows[indx].cells[8].text.tostring();         ordercheck = gdv.rows[indx].cells[9].text.tostring();     }      lblorderno.text = salesorderno;     lblsectionname.text = sectionname;     lbloutletname.text = outletname;     lblorderdate.text = orderdate;      loadorderreportdetailgrid(salesorderno); }  protected void gdvorderdetail_selectedindexchanged(object sender, eventargs e) {  } 

test sufficient know origin of event. exemple :

        private void datagrid1_selectionchanged(object sender, selectionchangedeventargs e)         {             if(datagrid1.selecteditem!=null)                 messagebox.show("aaaaaaaaaaa");         }          private void datagrid2_selectionchanged(object sender, selectionchangedeventargs e)         {             if (datagrid2.selecteditem != null)                 messagebox.show("bbbbbbbbbbb    ");         } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -