locked
When using UpdatePanel of ajax on GriView control then onselectedindexchanging event of GridView is not working. RRS feed

  • Question

  • User-808382924 posted

    When using UpdatePanel of ajax on GriView control then onselectedindexchanging event of GridView is not working.

    <section id="content1" class="Estimatecom_div">
    
                   <asp:UpdatePanel ID="UpdatePanel9" runat="server">
                   <Triggers><asp:AsyncPostBackTrigger ControlID="lbcs" EventName="click" /></Triggers>
                   <ContentTemplate>
                   <table>
                            <tr>
                                 <td colspan="4">
                                    <div style="margin-bottom:10px;Display:none">
                                        <h2>Approval Status</h2>
                                    </div>
                                </td></tr>
                <tr><td align="left"> Sanction Status</td>
                    <td style="width:120px" >
                        <asp:DropDownList ID="ddlSanction" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="ddlSanction_SelectedIndexChanged">
                            <asp:ListItem Selected="True" Value="0">Not Sanctioned</asp:ListItem>
                            <asp:ListItem Value="1">Sanctioned</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td align="right">
                        Section Office 
                    </td>
                    <td align="right" style="width: 62px">
                        <asp:DropDownList ID="ddlSecOfc" runat="server" AutoPostBack="True" 
                            onselectedindexchanged="ddlSecOfc_SelectedIndexChanged">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" ><div style="border-bottom:1px solid silver;padding-top:5px;margin-bottom:5px">
                    <asp:ImageButton ID="ImageButton2" runat="server" AlternateText="Image" 
                            onclick="ImageButton2_Click"></asp:ImageButton></div>
                      </td></tr>
                <tr>
       <td colspan="3" align="right">
                         <asp:LinkButton ID="btnApprove" runat="server" Font-Underline="false"
                            Text="Approval" CssClass="esti_lnkbtn"  onclick="btnApprove_Click" ></asp:LinkButton>&nbsp&nbsp&nbsp
                 <asp:LinkButton ID="lnkRever" runat="server" onclick="lnkRever_Click">Reversion</asp:LinkButton>
    
                 <asp:ModalPopupExtender ID="ModalPopupExtenderReversion" runat="server" 
                            BackgroundCssClass="Modal"
                            TargetControlID="lnkRever"
                            PopupControlID="ReversionPopUp"
                            PopupDragHandleControlID="ReversionHandle"
                            CancelControlID="img1">
                </asp:ModalPopupExtender>
                       
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        &nbsp;<asp:Label ID="lblNxtApp" runat="server" 
                            style="text-align: center; color: #006600; font-weight: 700; font-size: x-large; background-color: #FFFFFF"></asp:Label>
                    </td></tr>
                <tr><td colspan="4">
                 <div>
                 <asp:GridView ID="gvEst_Mas" runat="server" autogenerateselectbutton="false" 
                 onselectedindexchanged="gvEst_Mas_SelectedIndexChanged" 
                         onrowdatabound="gvEst_Mas_RowDataBound" onselectedindexchanging="gvEst_Mas_SelectedIndexChanging" style="margin-left: 0px" Width="16px" AllowPaging="true" onpageindexchanging="
    gvEst_Mas_PageIndexChanging" > 
    <SelectedRowStyle BackColor="AliceBlue" />
            </asp:GridView>
            </div></td></tr>
            </table>
            
            </ContentTemplate></asp:UpdatePanel>
            
        </section>
    

    Thursday, May 22, 2014 2:22 AM

Answers

  • User1918509225 posted

    Hi ,

    In  your code ,for  all your control in a updatepanel,while in your code 

    <Triggers><asp:AsyncPostBackTrigger ControlID="lbcs" EventName="click" /></Triggers>
    

    only when you fire a click on your "lbcs" control,your page will fire a asyncpostback.

    So  you need to  add trigger for your gridview selected changed event:

    <Triggers><asp:AsyncPostBackTrigger ControlID="gvEst_Mas" EventName="selectedIndexChanged"/><Triggers>

    If you want to your other control tirgger the page post ,you can add more in your triggers.

    <Triggers>
        <asp:PostBackTrigger ControlID="gvEst_Mas" />
        <asp:PostBackTrigger ControlID="lbcs" />
     </Triggers>

    Hope it can help you.

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2014 2:31 AM

All replies

  • User366904899 posted
     <asp:UpdatePanel ID="UpdatePanel9" runat="server">
                   <Triggers>
    	<asp:AsyncPostBackTrigger ControlID="gvEst_Mas" EventName="SelectedIndexChanged" />
    </Triggers>
                   <ContentTemplate>
                              // content
       </ContentTemplate></asp:UpdatePanel>

    Try with this

    Thursday, May 22, 2014 3:44 AM
  • User1918509225 posted

    Hi ,

    In  your code ,for  all your control in a updatepanel,while in your code 

    <Triggers><asp:AsyncPostBackTrigger ControlID="lbcs" EventName="click" /></Triggers>
    

    only when you fire a click on your "lbcs" control,your page will fire a asyncpostback.

    So  you need to  add trigger for your gridview selected changed event:

    <Triggers><asp:AsyncPostBackTrigger ControlID="gvEst_Mas" EventName="selectedIndexChanged"/><Triggers>

    If you want to your other control tirgger the page post ,you can add more in your triggers.

    <Triggers>
        <asp:PostBackTrigger ControlID="gvEst_Mas" />
        <asp:PostBackTrigger ControlID="lbcs" />
     </Triggers>

    Hope it can help you.

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2014 2:31 AM