updating an updatepanel without postback

1.9k Views Asked by At

I have two columns in a table,the dropdown 'ddlModelNumber' is dependent on the selected value of 'ddlServicerOrg'. The data in 'ddlServicerOrg' is very large so I don't want it to get rendered every time I change the selected item. I want to load data into 'ddlModelNumber' based on the selected value in 'ddlServicerOrg' without using jquery:ajax. So, is OnChange="_doPostBack('pnlModel','');" the right way to do it? I don't want large amount of data to get rendered again and again for'ddlServicerOrg'. Below is the code.

                <td>
                    <asp:DropDownList ID="ddlServicerOrg" runat="server" DataTextField="ListText" DataValueField="ID"
                        OnInit="ddlServicerOrg_Init" OnDataBound="ddlServicerOrg_DataBound" OnSelectedIndexChanged="ddlServicerOrg_IndexChanged"
                        AutoPostBack="false" AppendDataBoundItems="True" DataSourceID="ServiceLocationOrgODS" OnChange="_doPostBack('pnlModel','');">
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                <asp:UpdatePanel ID="pnlModel" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="ddlModelNumber" runat="server" AutoPostBack="false" DataSource='<%# GetServicedModelforServicePartner() %>'
                        DataTextField="Text" DataValueField="Value" AppendDataBoundItems="True" OnInit="ddlModelNumber_Init" OnDataBound="ddlModelNumber_DataBound" Enabled="false">
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                    </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
1

There are 1 best solutions below

0
On

You could do this with some JavaScript. You could have the selectedIndexChanged of the combobox write a value to a hiddenfield within and update panel that the second combobox is in. Then force an ajax postback on that panel to update the contents of the second combobox. An easy way to do this would be to have your combobox selectedindexchanged event click a hidden button in the panel that contains the second combobox.

http://keylimetie.com/blog/2007/12/3/how-to-make-an-ajax-postback-with-javascript/

That link can act as a guideline to do what what you want.