A
A
Alexeytur2019-12-13 10:00:52
JavaScript
Alexeytur, 2019-12-13 10:00:52

DropDownList event not triggered inside GridView?

Good afternoon.
Why can a DropDownList inside a GridView not fire the OnSelectedIndexChanged event?

<asp:UpdatePanel ID="updPnlTbl" runat="server" >                                                
            <ContentTemplate>
                <asp:GridView ID="gvTaskList" runat="server" AllowPaging="false"
                    ShowHeaderWhenEmpty="True" PageSize="5" AutoGenerateColumns="false" Width="100%"
                    CssClass=" Grid" SelectedRowStyle-CssClass="sel" AlternatingRowStyle-CssClass="alt"
                    PagerStyle-CssClass="pgr" PagerSettings-Mode="NumericFirstLast" DataKeyNames="TaskID"
                    OnRowDataBound="gvTaskList_RowDataBound" OnSorting="gvTaskList_Sorting"
                    AllowSorting="true" OnRowCreated="gvTaskList_RowCreated"    >                    
                    <Columns>
                        <asp:TemplateField HeaderText="Статус" SortExpression="Status">
                            <HeaderTemplate>
                                <asp:LinkButton ID="lnkBtnStatusHeader" runat="server" CommandName="Sort" CommandArgument="Status">Статус</asp:LinkButton><br />
                                <asp:TextBox ID="tbStatus" runat="server" OnTextChanged="tbStatus_TextChanged" OnPreRender="tbStatus_PreRender" Width="90px"   AutoPostBack="true"></asp:TextBox>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" runat="server" Text='<%#Eval("Status") %>' Visible="false" />                                
                                <asp:DropDownList ID="ddlStatus" runat="server"  OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged" 
                                      OnTextChanged="ddlStatus_TextChanged"  OnPreRender="ddlStatus_PreRender" AutoPostBack="true" > </asp:DropDownList>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
                            <HeaderStyle Width="1%" />
                        </asp:TemplateField>                        
                    </Columns>
                </asp:GridView>        
             </ContentTemplate>                                       
    </asp:UpdatePanel>

This raises the Page_load event with PostBack=true, but does not call OnSelectedIndexChanged.
Googled the question, the main answers were - don't change GridView during PostBack. But that's how I do it.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2019-01-23
@Almazmr

Fortune teller mode: on
I guess in condition
should name be replaced with elem? because name is just a name, and elem is a name_date pair.

V
Vladimir Kuts, 2019-01-23
@fox_12

Because name.split('___')[1] is
maybe better like this?:
Number(name.split('___')[1].match( /\d+/ ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question