Populating a DB from a DropDownList Control

W

wcaruso

Good afternoon. I'm in the midst of writing up a pretty "basic" web
form and having some difficulties. I'm completely open for
suggestions. I'm using VS.net 2003, and what iwould like to accomplish
is to have a form with two dropdown Boxes a button and a datagrid to
display what was selected from the drop downs. One of the drop downs
values can not be used more than once while the others can be repeated
as often as they like. Being that I'm a somewhat new developer I'm
finding even the easiest tasks to be difficult. The DropDownBoxes are
server controls that I pre-populated from in the aspx html. These
values will change very infrequently, so editing the aspx to add more
shouldn't be a problem. The problem that I'm having is that I can not
get any values to show in the Data Grid. These values must also be
stored in a DB that I created. I'm confused on what Data Controls I
would need, how to configure them. I have a SQLConnection control and
it is, to my belief able to connect to the DB. I have also read to
have a SQLCommand control and a SQLDataAdapter control. Any assistance
is greatly appreciated. Thanks, Will
 
S

shil

Try this.

Dim myConn as SqlConnection = New SqlConnection(Connection string)
Dim myDa as SqlDataAdapter = new SqlDataAdapter("Select query", myConn)

myConn.Open()
Dim myDs as DataSet = New DataSet

myDa.Fill(Ds, "All") '{populate Dataset with data

'Bind data to datagrid
datagrid1.DataSource = Ds
datagrid1.DataBind()
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top