[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Ajax with drop downlist

Asked by R8VI in .NET, C# Programming Language, Programming for ASP.NET

Tags: c#, asp.net

Hi,

I have the code below I am bascially making a call to the DB on selected index changed of the first drop down.

But nothing seems to get populated in the second drop down.

If I change thebut autopost true for first drop down it works fine but the whole page refreshes i dont want that

Please help

R8VI
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
aspx page 
 <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        Country
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:DropDownList ID="ddl_1" runat="server" OnSelectedIndexChanged="ddl_1_SelectedIndexChanged"
                    Width="171px">
                    <asp:ListItem>147</asp:ListItem>
                    <asp:ListItem>156</asp:ListItem>
                    <asp:ListItem>146</asp:ListItem>
                </asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <br />
        City
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="ddl_2" runat="server" Width="167px">
                </asp:DropDownList>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddl_1" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </div> 
c# 
       protected void ddl_1_SelectedIndexChanged(object sender, System.EventArgs e)
        { 
            if (!IsPostBack)
            {
                ddl_2.DataSource = BTU.GtByTForMl(int.Parse(ddl_1.SelectedItem.Value));
                ddl_2.DataBind();
            }
        }
[+][-]11/05/09 09:58 AM, ID: 25752070Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:02 AM, ID: 25752117Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 10:04 AM, ID: 25752128Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 05:03 PM, ID: 25755847Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 05:04 PM, ID: 25755853Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625