Reload DataGrid on DropDownList onChangeIndex

H

hansiman

I have a drop down list and a datagrid.
The dropdownlist is populated on pageload.
I' like to databind the datagrid when user selects in dropdownlist:

Something like this:

Private Sub cbo1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cbo1.SelectedIndexChanged

dgr.DataSource = GetDataSet(connection, _
"SELECT * FROM Orders Where CustomerID = " _
"'" & cbo1.SelectedItem.Value & "';")
dgr.DataBind()
End Sub


If I add a button it works just fine.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
dgr.DataSource = GetDataSet(connection, _
"SELECT * FROM Orders Where CustomerID = " _
"'" & cbo1.SelectedItem.Value & "';")
dgr.DataBind()
End Sub


/morten
 
M

Michael Ramey

And your problem is...??..(since you never told us)

If I had to guess, your code isn't fired when you create the sub
"cbo1_SelectedIndexChanged". because you haven't set "AutoPostBack"
attribute is set to "true" for this control. By default it is false.

HTH,
--Michael
 
H

hansiman

you're the man :)

- I'm just getting into asp.net (finding time in between classic asp
projects. cant wait to put my new sills to good use).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top