473,385 Members | 1,312 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,385 software developers and data experts.

Display data in datagrid using dropdown selection

Hi All,

In my form I have created a dropdown box which is populated with data
from a database on page load and i have also created a dropdwon box and
what i intend on doing is displaying data re;ated to dropdown selection
into a data grid.

I have attached part of the code.

Can someone please help me out on this cos i am really finding it
difficult doing it with the data reader.

Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Dim str As String
Dim sqlstr As String
Dim ds As DataSet
Dim ds1 As New DataSet

Dim sqlcmd As New SqlClient.SqlCommand
Dim dataadp As New SqlClient.SqlDataAdapter

SqlConnection1.Open()
str = DropDownList1.SelectedItem.Text
Label1.Text = str

sqlstr = "select * from Resources where Module_name=" + str
Label3.Text = sqlstr
sqlcmd = New SqlClient.SqlCommand(sqlstr, SqlConnection1)
dataadp = New SqlClient.SqlDataAdapter(sqlcmd)
dataadp.SelectCommand.Connection = SqlConnection1
SqlCommand1.CommandText = sqlstr
SqlCommand1.ExecuteReader()

Apr 2 '06 #1
1 1609
Something like this to fill a dataset & Change the query selection depending
on the value of a dropdownlist

Dim sqlString As String = "SELECT * FROM People where person='" &
drpPeopleDropDown.SelectedValue & "';"
Dim sqlDA As New SqlClient.SqlDataAdapter
Dim sqlCommand As New SqlCommand(sqlString, sqlConnection)
Dim Peopl as New Dataset
sqlDA.SelectCommand = sqlCommand

Try
sqlConnection.Open()
sqlDA.Fill(People)
Catch ex As Exception
'TODO exception handling
Finally
sqlConnection.Close()
End Try

Then bind a DataGrid to the dataset

HTH

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net

<pr***************@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Hi All,

In my form I have created a dropdown box which is populated with data
from a database on page load and i have also created a dropdwon box and
what i intend on doing is displaying data re;ated to dropdown selection
into a data grid.

I have attached part of the code.

Can someone please help me out on this cos i am really finding it
difficult doing it with the data reader.

Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Dim str As String
Dim sqlstr As String
Dim ds As DataSet
Dim ds1 As New DataSet

Dim sqlcmd As New SqlClient.SqlCommand
Dim dataadp As New SqlClient.SqlDataAdapter

SqlConnection1.Open()
str = DropDownList1.SelectedItem.Text
Label1.Text = str

sqlstr = "select * from Resources where Module_name=" + str
Label3.Text = sqlstr
sqlcmd = New SqlClient.SqlCommand(sqlstr, SqlConnection1)
dataadp = New SqlClient.SqlDataAdapter(sqlcmd)
dataadp.SelectCommand.Connection = SqlConnection1
SqlCommand1.CommandText = sqlstr
SqlCommand1.ExecuteReader()

Apr 2 '06 #2

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

Similar topics

0
by: anonymous | last post by:
Thanks Michelle, How could I achieve the second one.I do not like Flashing windows in response to selection of an item. I agree the data transfer is very little but the same data transferred for...
1
by: govindaraj_200152 | last post by:
Hi, I am using two Drodowns with ASP.NET Datagrid/(ASP.20 GridView) . What i want is , on selecting the first dropdown i want to populate the second dropdown based on the selection. The dropdown...
2
by: Wysiwyg | last post by:
I was hoping to get some opinions on the efficiency of various methods of reusing the same dropdown list data. Here is the situation: Multiple panels on maintenance pages with TAB menus across...
1
by: Vijay Kerji | last post by:
Hi, I have a datagrid with dropdown list and Remove hyperlink in it as columns. When I remove a row from the datagrid, Dropdown list selection is retaining its previous value. i.e, removed...
1
by: murphy | last post by:
Hello, I've run into a potentially wrong design decision on a project and want to find out if my intended change is the best fix. I have a page that displays historical time-series data using...
3
by: riyaz | last post by:
dear mvps i am a beginner for asp.net ,i want to produce the data in the datagrid based upon the selection from the dropdown list. plz give me some code for me to develop this regards...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
5
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi, I wonder if anyone can help? I've got a web form (intranet), .net version 1.1. I've got a sub that populates a datatable in a dataset, dependent on a dropdown field selection. This works...
2
by: Iain Wilson | last post by:
Hi Can anyone please advise if this is possible and if so how I would go about it (a pointer to an example would be greatly appreciated). Using C# - Web Application I have a DropDownList with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.