Dynamic dropdown list
-
Hi, Can anybody send me a tutorial on how to handle a dynamic dropdownlist in vb asp.net. What I want is to have 2 dropdownlist. In my first dropdownlist, I have the list of departments. Then in my second dropdown list, I have the list of the members of each department. So if I select Human Resource in my first drop down list, members from HR team in my second dropdown list will be enumerated and so on with other department. I really appreciate your help. Thanks in advance.
-
Hi, Can anybody send me a tutorial on how to handle a dynamic dropdownlist in vb asp.net. What I want is to have 2 dropdownlist. In my first dropdownlist, I have the list of departments. Then in my second dropdown list, I have the list of the members of each department. So if I select Human Resource in my first drop down list, members from HR team in my second dropdown list will be enumerated and so on with other department. I really appreciate your help. Thanks in advance.
What you need to do is first fill the first dropdownlist(department) at the page load event and then on the SelectedIndexChanged fill the second dropdownlist(members) by getting the filtered records(members only associated with selected department).
Best Regards, Apurva Kaushal
-
What you need to do is first fill the first dropdownlist(department) at the page load event and then on the SelectedIndexChanged fill the second dropdownlist(members) by getting the filtered records(members only associated with selected department).
Best Regards, Apurva Kaushal
-
Thank you very much but can you show me how? Because Im a newbie with this thing. I really appreciate it. Thanks in advance.
If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?
Best Regards, Apurva Kaushal
-
If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?
Best Regards, Apurva Kaushal
-
If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?
Best Regards, Apurva Kaushal
Hi.. yes I already filled up a dropdown list coming from SQL data as my datasource. But I dont know how to code the second part that you are saying. "Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records." Can you show me in vb.net code? I really appreciate it. Thanks.
-
Hi.. yes I already filled up a dropdown list coming from SQL data as my datasource. But I dont know how to code the second part that you are saying. "Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records." Can you show me in vb.net code? I really appreciate it. Thanks.
What you need to do in the second part is you have to get the ID value of the item selected in the department dropdownlist(when you would have bind the first dropdownlist then you would have assigned the text and value field, you need to get that value of the selected item). And once you are having that you can query to get the records associated with that department ID. And once you get the desired records you have to bind the second dropdown exactly like you have done with the first one. I think now it would have been clear. :)
Best Regards, Apurva Kaushal