locked
GridView - SelectedIndexChange not firing - SOS RRS feed

  • Question

  • User-1664485818 posted

    Hi folks, I have tried to make the gridview more mobile friendly. I added the footable  jQuery plugin  http://fooplugins.com/plugins/footable-jquery/

    but now the SelectedIndexChange will not fire!! any help or pointers much appreciated /:-(

    Code below

     <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
                  <ContentTemplate>
                      <asp:GridView ID="GridView1" CssClass="footable" runat="server" AutoGenerateColumns="False" Style="max-width: 130%" DataSourceID="SqlDataSourceGridViewSearchResults" AutoPostback= "Flash" DataKeyNames="ProductID,GarageID"           
                      EmptyDataText="Sorry we don’t have that tyre, please email us your requirements and we will add it to our Search engine – service@tyrescanner.net"
                      OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                   
                       <Columns>
                            <asp:BoundField DataField="GarageTown" HeaderText="Garage Location"></asp:BoundField>
                 
                             <asp:TemplateField HeaderText="Tyre Model">
                                <ItemTemplate>
                                    <asp:Label ID="lblBrand" runat="server" Text='<%#Eval("Brand")+ " " + Eval("TyreModel")%>' ></asp:Label>
                                    <br />
                                    <asp:Label ID="Label1" runat="server" Text="£" Height="16px" Width="4px" Font-Bold="True"></asp:Label>
                                    <asp:Label ID="lblCurrency" runat="server" Font-Bold="True" Text='<%#Eval("ProductUnitSalePrice")%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                      
                            <asp:BoundField DataField="TyreType" HeaderText="Tyre Type" />
                    
                            <asp:TemplateField HeaderText="Noise Level">
                                <ItemTemplate>                          
                                    <asp:Label ID="lblBrand" runat="server" Text='<%#Eval("NoiseEmission")+ "dB"%>' ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                                         
                           <asp:BoundField DataField="FuelEfficiencyCategory" HeaderText="Fuel Efficiency" />
                                             
                           <asp:BoundField DataField="WetGrip" HeaderText="Wet Grip" />
                                      
                          <asp:TemplateField HeaderText="Select Quantity">
                                <ItemTemplate>                                                                                              
                                    <asp:DropDownList ID="txtQuantity" runat="server" OnSelectedIndexChanged="txtQuantity_SelectedIndexChanged"
                                        AutoPostBack="true" Width="55px" Height="32px" DataFormatString="{0:£ 0.0}" ForeColor="Black">
                                        <asp:ListItem Text="0" Value=" " />
                                        <asp:ListItem>1</asp:ListItem>
                                        <asp:ListItem>2</asp:ListItem>
                                        <asp:ListItem>3</asp:ListItem>
                                        <asp:ListItem>4</asp:ListItem>
                                        <asp:ListItem>5</asp:ListItem>
                                    </asp:DropDownList>
                                      <asp:Label ID="Errorlabel" runat="server" Text=""></asp:Label><p></p>
                                      <asp:Label ID="LabelTotalPoundSign" runat="server" Font-Bold="true" Text="Total £" Height="16px" Width="4px"></asp:Label>&nbsp;
                                      <asp:Label ID="lblTotal" runat="server"  Font-Bold="true" Text="0.00" Width="30px" ></asp:Label><p></p>                          
                                      <asp:LinkButton runat="server" class="btn btn-custom btn-sm" style="color:white" >Order &raquo;</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>                                 
                      
                           <asp:BoundField DataField="GarageID" HeaderText="ID"  Visible="false" />
                    </Columns>
                </asp:GridView>
              </ContentTemplate>
           </asp:UpdatePanel>
    
    
      protected void txtQuantity_SelectedIndexChanged(object sender, EventArgs e)
            { 
                DropDownList txtQuantity = sender as DropDownList;
              
                GridViewRow row = (GridViewRow)txtQuantity.NamingContainer;
              
                var Pricevalue = double.Parse(((Label)row.FindControl("lblCurrency")).Text);
               
                Label lblTotal = row.FindControl("lblTotal") as Label;
    
                lblTotal.Text = Convert.ToString(Pricevalue * Convert.ToInt32(txtQuantity.SelectedItem.Text));
            }



    Tuesday, February 28, 2017 10:24 PM

Answers

  • User3690988 posted

    Are you sure that it's the jQuery plugin, and not the UpdatePanel?  Try commenting out the UpdatePanel, or adding a Trigger for the SelectedIndexChanged event.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 1, 2017 1:26 PM

All replies

  • User-1838255255 posted

    Hi brucey,

    According to your description, I am not clear how not work.

    1. the SelectedIndexChanged event not work after you use the FooTable  jQuery plugin?  it could be triggered before?

    2. Please add a break point to the SelectedIndexChanged event, then check it trigger this event or not. 

    3. Hope your detailed code and description.

    Best Regards,

    Eric Du 

    Wednesday, March 1, 2017 7:47 AM
  • User-1664485818 posted

    Hi Eric, the SelectedIndexChanged worked ok before I used the FooTable  jQuery plugin. I have added a break point to the SelectedIndexChanged, it's not being triggered!!

    Wednesday, March 1, 2017 7:54 AM
  • User3690988 posted

    Are you sure that it's the jQuery plugin, and not the UpdatePanel?  Try commenting out the UpdatePanel, or adding a Trigger for the SelectedIndexChanged event.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 1, 2017 1:26 PM