473,399 Members | 4,177 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,399 software developers and data experts.

Populating a DB from a DropDownList Control

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

Nov 19 '05 #1
2 1084
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()

Nov 19 '05 #2
wcaruso welcome to the forum..
Try looking at this sample at:-
http://aspnet101.com/aspnet101/aspne....aspx?code=md2
It should guide you.
Also try seeing through quickstart at:-
http://asp.net/Tutorials/quickstart.aspx
Hope that helps
Patrick

<wc*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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

Nov 19 '05 #3

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

Similar topics

1
by: Hugh McLaughlin | last post by:
Hello Everyone and thanks for your help in advance. I am developing a class library that reads a SQL Server table of names and ID's. I want to populate a dropdownlist with the data, however, names...
1
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList...
3
by: jayfischer91 | last post by:
The method below belongs to a class. The method accepts a dropdownlist as a parameter. Is there any disadvantage to passing in the control and having this method populate it as opposed to passing...
3
by: RFS666 | last post by:
Hello together, I tried to find out about populating an asp.net server control (a dropdownlist) from the clientside jscript, but I didn't find a solution up to now. I cannot use a html...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
6
by: p.mc | last post by:
Hi all, I have a MS SQLServer database which has two tables, 'images' and 'photographers'. The photographer table contains a field for PhotographerID and a one for PhotographerName. The image...
6
by: needin4mation | last post by:
I have a gridview and a dropdownlist. If I change the ddl, the gridview populates. That is what I want. But what I don't want is for it to happen the first time they get to the page. I know I...
2
by: Phil Sandler | last post by:
I am trying to do something which seems (to me) to be very simple, and yet I can't seem to figure it out. I have a gridview and a formview. When a user clicks "select" in the gridview, the...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
1
by: Problematic coder | last post by:
Here is the main code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load buildYearDDLs(FindControl("ddlSample")) End sub Private Sub...
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: 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
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
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.