473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reload DataGrid on DropDownList onChangeIndex

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
Nov 18 '05 #1
2 2615
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

"hansiman" <ha***@hotmail.com> wrote in message
news:6l********************************@4ax.com...
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

Nov 18 '05 #2
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).
On Tue, 3 Feb 2004 15:17:12 -0500, "Michael Ramey" <raterus@localhost>
wrote:
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

"hansiman" <ha***@hotmail.com> wrote in message
news:6l********************************@4ax.com.. .
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
10
by: riversmithco | last post by:
This should be easy, How do I reload a page so that it makes the server think it's the first time the page has been loaded? Thanks
2
by: Steve Pierce | last post by:
I am having some issues with a runtime dropdownlist in a datagrid. The issue is that I cannot get ViewState to fill the selected index of a runtime dropdown properly on postback. I do not want to...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.