Filter dropdown list from another dropdown list

Help Please!!!

I am trying to filter the data in a dropdown list from information chosen in another dropdown list.
1st table has modification types, 2nd table has modifications. When the user chooses the modification type needed, then only those modifications should appear in the 2nd list.

mydata7 = New SqlDataAdapter("Select * from ModificationList ", myconnection)
ds7 = New DataSet
mydata7.Fill(ds7, "table")
Dim dr7 As DataRow
ddlModification.Items.Add("Please select Modification ...")
For Each dr7 In ds7.Tables(0).Rows
mydata8 = New SqlDataAdapter("Select * from StudentList", myconnection)
ds8 = New DataSet
mydata8.Fill(ds8, "Table")
Dim dr8 As DataRow
ddlStudentName.Items.Add("Please choose Student ...")
For Each dr8 In ds8.Tables(0).Rows

this code works to fill the second ddl with all the modifications - now I just need to know how to add a filter - I did try instantiaing a dataview and putting the filter there - it just didn't work
thanks in advance
7/23/2004 5:29:00 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 28

For the first ddl set AutoPostBack to true, which posts the page when ever it's value is changed. On the SelectedIndexChanged event of first dll, query the database to populate the second ddl
7/23/2004 6:55:47 PM
Thanks for the help - I am getting somewhere, but not where I need to be -

Here is the code I used in the selected index changed event

Private Sub ddlModificationType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlModificationType.SelectedIndexChanged
Dim myconnection As SqlConnection
Dim mydata As SqlDataAdapter
Dim strConn As String
Dim mydata7 As SqlDataAdapter
Dim ds7 As DataSet
strConn = "server=localhost;uid=sa;password=;database=master;"
myconnection = New SqlConnection(strConn)
mydata7 = New SqlDataAdapter("Select * from ModificationList ", myconnection)
ds7 = New DataSet
mydata7.Fill(ds7, "ModificationList")
Dim dav1 As New DataView(ds7.Tables("ModificationList"))
Dim strFilter As String
strFilter = "ModTypeID = " & (ddlModificationType.SelectedIndex + 1).ToString
dav1.RowFilter = strFilter
ddlModification.DataSource = dav1
End Sub

but now my second ddl gives me this
for every row in the ddl
Any suggestions???
7/23/2004 8:39:01 PM
Please ignore the post prior to this one!!!

I found the answer and made it work
thanks again
7/23/2004 9:09:24 PM
I'm having the same problem getting a System.Data.DataRowView instead of the value out of my database.  How did you fix yours?  I post my problem here  Thanks inadvance!
11/19/2004 2:18:02 PM

Similar Artilces:

one dropdown list affecting another dropdown list
I am desgining a website using VB.NET wherein the data items of one dropdown list depends on the selection of a data item in the previous dropdown list something similar to selection of country USA from 1st dropdown list...triggers 2nd dropdown with list of states in USA How can this be accomplished.... Any help will be appreciated... Thanks & Best Regards... hi boy,first I suggest turn on auto postback on first dropdownlist. In select index changes(first dropdownlist) - select value on second dropdownlist My blog is here.Please remember to 'Mark as Answer' i...

Dropdown list bound to another dropdown list
I have two dropdown lists on my page. The first contains a list of names and the second contains a list of hardware devices. My problem is: When i choose a name from the first dropdown i need the second to become populated with their related devices. This works fine, however if i then change the name in the first dropdown list, it adds another set of devices to the devices dropdown list. The way i want it to work is to refresh the devices dropdown when the name is changed. So that only that persons related devices show up (in the second dropdown)  Any help would be much apprecia...

Populate a Dropdown List based on the value of another Dropdown List
 Hi ALL,    I have two Dropdown List.I need to Populate second Dropdown List based on the value of first Dropdown List.I am n't using Update Panel.Pls suggest me RegardsSri ASP.NET AJAX Cascading DropdownDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!   just populate second dropdown in SelectedIndexChanged event of the first dropdown. Muhammad ShoaibSoftware Engineer,Lahore, (U/C)--------------------------------Mark it as ANSWER if it Helps U   Check out this link with co...

Can I populate a Dropdown list in a GridView from another Dropdown list
Hi there, I have a Gridview control that contains 2 DDLs. The first one is populated on page load (from a Generic list in the code behind) and is working with no problems. I want to populate the 2nd DDL by making a selection in the first DDL which in turn would call a DB method and cause a postback. I've tried using the "OnSelectedIndexChanged" method for the DDL and the "FindControl" method for the 2nd DDL, but the GridView can't find it on Postback and throws an error. I've also tried using the "onSelectedIndexChanged" method for the GridView bu...

Filling a dropdown list, based on a selection from another dropdown list
This seemed like a simple venture, and may be, but with my limited knowledge, I am having a problem... Basically, I have a page that is gathering information. I want a user to be able to select a value from a dropdown list... On Auto postback I would like to make a second listbox visible and bind data to it based on the selection from the first. (While keeping the value of the first listbox available) Right now I am filling my dataset with the tables used in the page load event and setting my second listbox.visible to false. in the SelectedIndex_change event of the first...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

Selection in one dropdown list effecting the visibility of another dropdown list
I have two drop down lists. They are not databound. We'll called them dropdownlist1 and dropdownlist2.Basicly, I want people to choose an object in the first dropdownlist. Depending on their selection, it will make certain items in dropdownlist2 invisible.Currently my thought is to have something in the lines of the following (In the dropdownlist1 - SelectedIndexChanged - Postback being set to Auto)if dropdownlist1.text = "Such and such" then(this is where I would declare which options are available)However, I do not know the proper syntax of saying make the following item...

automatically generating content in a dropdown list based on the selection of another dropdown list
hi i currently have a "categories" dropdown list i'm using to help filter data in a datagrid (have it setup using data and table adapters). i've introduced another dropdown list (called subcategories) to filter the datagrid so it only displays records that fit in both the category and all works fine, but i'm wanting to set it so the subcategories dropdown list gets generated on the client-side depending on the category selected. does anybody have any quick tutorials or a quick explination on how i could do this? am i missin...

populate a dropdown list on the basis of other dropdown list
I need to populate a dropdown list on the basis of other dropdown list. Both dropdwon list are datasourced with SQL datasource. I tried the SQL datasource where query . but it will need a post back. I dont want my form to be postback. I guess this is what AJAX is for but i really dont know how to get this with AJAX in a simple and quick way..... or it is not simple and quick ????Mark as answer if anybody's post has helped you It can be simple and quick.  See this video: And also the tutorial on how to use the Cascading Dropdow...

Hide dropdown list based on other dropdown list selection
Hi, i have an aspx page with a form. I want to hide dropdown list b depending on what is selected for dropdown list a. I need to do this client side Im new to this so any assistance would be appreciated. Thanks in advance   could you explai briefly about your requirements? you want to maske dropdownlist b as invisible if you select any item on dropdownlist a? or you want to make it invisible for a specific item?   Hi,     Change the visibility of dropdownlist as false on selected index change. Private Sub ddl_a_SelectedIndexChanged(ByVal sender As Syste...

Using a selection from a dropdown list to fill in a second dropdown list.
Hi,  I am new to the web programming area and looking for some help.  I have a situation where, like i said in my subject trying to base the list in the ddl2, to be based on the selection from ddl1.  What do i all need to include to do this.  As of now, I have two seperate SQL data sources, with the first one I have it just selecting from our database.  For the second list, I have a second sql data source that does a selection of a different column from teh same database but in the where clause have a parameter that will equal the selection from teh first.. &n...

How to get value from first dropdown list to second dropdown list
Hi Does soneone know hot to get value from first dropdown list to second dropdown list or remove it from seond dropdown list? I have a web form page. On the page, there are two dropdown lists, one Add button, and one Remove button . First dropdown list has four list items. Second one does not have list item yet. When select a item from first dropdown list, then click "add" button. I want it to apear in the second dropdown list without reload the page. Or select item from second dropdown list, and click "Remove" button. it will remove from second list. Please help. &nb...

How to combind two dropdown list values into one dropdown list?
Hi All, I refered some websites, they are combinding two dropdown list values into single, but i don't know .Net will support it or not? If any body knows it plz tell me how to achieve it?? EX: Go to and select Functional Area dropdown list there u can see main & sub category names in one dropdown list!!!   Thanks, Aswath.  hi just concatenate , or - for ex:Dropdownlist1.Datatextfield= maincategory & "," & Subcategory Regards,M.VenkatesanMy Blog : http://venkat-dotnetsamples.blogspot.comPlease remember to click “Mark as Answer” on the pos...

Problem with 2 dropdown lists (second dropdown list reset automatically)
My Question is pretty simple.I have two dropdown lists. Once I clicked on one then second one gets populated (through SelectedIndexChanged and with AutoPostBack = true) now I am selecting the value in the second dropdown list and then hitting submit button. I am now sending these values to another page. but hte value in second drop downlist is always selected the first value (though i have selected the item other than first one)I am loading first dropdownlist in page load and under (if (!IsPostBack){ } )This is very silly things happening any bdoy has any idea about this or faced the same pr...