Protected Sub ddlState_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlState.SelectedIndexChanged
Select Case ddlState.SelectedValue
Case "0"
If True Then
ddlCity.Enabled = False
Exit Select
End If
Case "1"
If True Then
Exit Select
End If
Case "2"
If True Then
ddlCity.Enabled = True
ddlCity.Items.Clear()
ddlCity.Items.Add("city4")
ddlCity.Items.Add("city5")
ddlCity.Items.Add("city6")
If you set AutoPostBack="true" for ddlCity and add a SelectedIndexChanged event for ddlCity, you can get its value there:
Private Sub ddlCity_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlCity.SelectedIndexChanged
Dim ddl2val As String
ddl2val = ddlCity.SelectedValue
End Sub
i just have a form on my page with multiple updatepanels and a submit button which gets the values
i even removed the updatepanel of the two dropdownlists and in that case also i get the first value of second dropdown instead of the actual selected value!!!
really confused .shoudl i be using the cascading ajax dropdown instead!!!
keyvan1
Member
86 Points
272 Posts
second dropdown get value problem in updatepanel
Nov 17, 2012 05:07 PM|LINK
Hi
I have 2 dropdown in updatepanel the second dropdown is populated by selection of first one
i cannot get the selectedvalue or text of second dropdownlist .it return the first value always
i read an article to check it in pageload event but in my case i do not know how
here is the code:
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlState" runat="server" Width="205px"
AutoPostBack="True" onselectedindexchanged="ddlState_SelectedIndexChanged"
Height="20px">
<asp:ListItem Value="0">----</asp:ListItem>
<asp:ListItem Value="1">province1</asp:ListItem>
<asp:ListItem Value="2">province2</asp:ListItem>
</asp:DropDownList>
<br />
<asp:DropDownList ID="ddlCity" runat="server" Width="205px" ></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub ddlState_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlState.SelectedIndexChanged
Select Case ddlState.SelectedValue
Case "0"
If True Then
ddlCity.Enabled = False
Exit Select
End If
Case "1"
If True Then
ddlCity.Enabled = True
ddlCity.Items.Clear()
ddlCity.Items.Add("city")
ddlCity.Items.Add("city2")
ddlCity.Items.Add("city3")
Exit Select
End If
Case "2"
If True Then
ddlCity.Enabled = True
ddlCity.Items.Clear()
ddlCity.Items.Add("city4")
ddlCity.Items.Add("city5")
ddlCity.Items.Add("city6")
Exit Select
End If
End Select
End Sub
paindaasp
Star
12092 Points
2035 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 05:34 AM|LINK
If you set AutoPostBack="true" for ddlCity and add a SelectedIndexChanged event for ddlCity, you can get its value there:
Private Sub ddlCity_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlCity.SelectedIndexChanged Dim ddl2val As String ddl2val = ddlCity.SelectedValue End Subkeyvan1
Member
86 Points
272 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 06:26 AM|LINK
i set the second dropdownlist ddlcity autopostback to true and and set the selected index changed
it does not work how should i get the value when i submit when i click the button then!!
ramiramilu
All-Star
95503 Points
14106 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 09:46 AM|LINK
probably something in your Page_load is messing up...debug your code line by line there....page load might be resetting the DDLs...
thanks,
JumpStart
keyvan1
Member
86 Points
272 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 09:49 AM|LINK
my page_load is empty
i just have a form on my page with multiple updatepanels and a submit button which gets the values
i even removed the updatepanel of the two dropdownlists and in that case also i get the first value of second dropdown instead of the actual selected value!!!
really confused .shoudl i be using the cascading ajax dropdown instead!!!
RameshRajend...
Star
7983 Points
2099 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 12:48 PM|LINK
http://stackoverflow.com/questions/13095455/unable-to-get-selectedvalue-from-dropdownlist
keyvan1
Member
86 Points
272 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 12:54 PM|LINK
can u tell me how to bind the second dropdown like the example in the link!!!!
i am confused
RameshRajend...
Star
7983 Points
2099 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 01:03 PM|LINK
my link dropdowns
If (IsPostBack) { ddlSite.Datasource = GetSites(); ddlSite.Databind();// binding first dropdown ddlPlant.DataSource() = GetPlant(ddlSite.SelectedValue);// binding second dropdown ddlPlant.Databind(); }keyvan1
Member
86 Points
272 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 01:08 PM|LINK
I saw the codes but my code structure is different!! look at the codes above
what should i set my datasource to!!!
my first dropdown is static in my aspx page
and look at the second code!!
RameshRajend...
Star
7983 Points
2099 Posts
Re: second dropdown get value problem in updatepanel
Nov 18, 2012 01:13 PM|LINK
hmm
ok u can look another sample
http://stackoverflow.com/questions/9341640/update-panel-and-dropdown-selected-index-change-issue
Thank you...