hi, i am working on developing an application with dropdown list. actually i have populated the data to the dropdown list. i am just looking forward to know how to get the item when its state is changed without any submit buttons. i was trying to use onselectedindex
changed. but i am not able to get through properly. i am not abe to get syntax working properly. i want the value in the dropdownlist as a string so that when an item is selected i would display appropriate details about the item. any help would be highly
appreciated. thanks -sriram
Set your dropdownlist property "Autopostback=True" and then write a function that handles the "selectedindexchanged" event. Example:
Private Sub lst_searchby_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_searchby.SelectedIndexChanged
'do your stuff here
End Sub
hi, the method works fine for a single dropdown list. if i have multiple dropdown lists on the same page i am not able to get the values for all. any suggestions.. thanks -sriram
You could hookup the same eventhandlers to all your dropdown lists, when the selected index is changed on any of the dropdownlist control, the event will be fired. To get the selected values for all dropdownlist on the same page, you need to enumerate thru
all dropdownlist controls. One way to make it easier is to add the reference for all dropdownlist controls into an ArrayList during Page_Load. Hope this helps, Ting-hao
This posting is provided "AS IS" with no warranties, and confers no rights.
I am trying to solve a problem that is a variation of this one. First. I have two DDLs in one form, each one loads dynamically from a different dataset. Second. The user should select one value in each DDL and click a submit button Third. It should bring a
page with values in a datagrid based on a filtered ds based on the chosen values of the first page. I am succesfully loading the values from the datasets. Hoever I cannot pass the values that are chosen to the results page. Everytime the user presses the submit
buton only the default values form DDLs are sent. HELP PLEASE
NO MATTER WHAT I DO IT ALWAYS PASSES THE VALUES FOR THE FIRST ITEMS IN EACH DDL. THE DATASETS ARE DEFINED IN DREAMWEAVER TAGS AND RETURN THE VALUES FROM A DB JUST FINE BINDING THEM TO THE DDL's HERE IS THE PROCEDURE TO PASS THE VALUES Sub btnSubmitRubro_SendInfo(Sender
as Object, e As EventArgs) Dim strCategory As String Dim strCity As String Dim strURL as String Dim myCategoryDropDownList as DropDownList Dim myCityDropDownList as DropDownList myCategoryDropDownList = ddlCategory myCityDropDownList = ddlCity strCategory
= myCategoryDropDownList.SelectedValue strCity = myCityDropDownList.SelectedValue URL = mypage.aspx+"?ddlCategory="+strCategory+"&ddlCity="+strCity Response.Redirect(URL) End Sub HERE ARE THE DDL'S <form id="frmCategorySelect" runat="server"> </form>
Sounds like you are populating your drop down lists during every postback during page_load. This will effectively wipe-out any values selected by the user. Try wrapping your code that populates the drop down lists inside of an
if not page.ispostback then code block, and rely on veiwstate to maintain the values in these controls. Let me know if you have any questions.
let me clarify a couple of things? The ddls shouldn't postback until the user has chosen and pressed the submit button... Please notice that I am not using the autopostback property since I need the user to select each DDL before building passing the parameters.
Then and only then it should open the new URL (in a blank window) using the parameter included built with the procedure. To try your suggestion I am not sure where I should place the code block. I do not have any place except for the dreamweaver tags that
builds the dataset. Just to show you what is NOT working, try selecting the second tab at: hhtp://www.redenlace.com.bo/TARJETAHABIENTES/CardHolders_Home.aspx and then use the DDL's in the middle. Those that say "Rubro" and "Ubicación" and then press Consultar...
You will see that no matter what you choose the resulting page always shows back the same datagrid. Hope it is not too much trouble. THAN YOU IN ADVANCE
wvusriram
Member
615 Points
123 Posts
Dropdown list - selected index changed
Jun 20, 2003 02:02 PM|LINK
label
Member
480 Points
98 Posts
Re: Dropdown list - selected index changed
Jun 20, 2003 03:40 PM|LINK
Private Sub lst_searchby_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_searchby.SelectedIndexChanged 'do your stuff here End Subwvusriram
Member
615 Points
123 Posts
Re: Dropdown list - selected index changed
Jun 20, 2003 03:55 PM|LINK
wvusriram
Member
615 Points
123 Posts
Re: Dropdown list - selected index changed
Jun 20, 2003 04:15 PM|LINK
tinghaoy
Participant
1140 Points
228 Posts
Microsoft
Re: Dropdown list - selected index changed
Jun 20, 2003 05:16 PM|LINK
hooligannes9...
All-Star
16504 Points
2917 Posts
Re: Dropdown list - selected index changed
Sep 26, 2003 08:52 PM|LINK
ndinakar
All-Star
49092 Points
6868 Posts
Moderator
MVP
Re: Dropdown list - selected index changed
Sep 26, 2003 09:48 PM|LINK
Dinakar Nethi
Life is short. Enjoy it.
***********************
hooligannes9...
All-Star
16504 Points
2917 Posts
Re: Dropdown list - selected index changed
Sep 27, 2003 12:07 AM|LINK
NetProfit
Contributor
6278 Points
1252 Posts
Re: Dropdown list - selected index changed
Sep 27, 2003 12:14 AM|LINK
hooligannes9...
All-Star
16504 Points
2917 Posts
Re: Dropdown list - selected index changed
Sep 27, 2003 12:28 AM|LINK