473,804 Members | 3,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1098
Try this.

Dim myConn as SqlConnection = New SqlConnection(C onnection 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.DataS ource = Ds
datagrid1.DataB ind()

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.goo glegroups.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
345
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 in the table may appear more than once. I only want to display the name in the dropdownlist once. My initial thought wat to create an arraylist, then loop through each record, adding a new name upon each new name encountered. But I want the name...
1
1988
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 control to the page. Then I created a data connection to my table... I right clicked and told it to generate a dataset (which it created dataset1).
3
1548
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 back a datareader from this method and having the webform populate it? It seems to work great! Just wondering if there may be a disadvantage to passing a control. Oh yea, by the way, it is just passing a pointer to the control, right? Or...
3
2649
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 dropdownlist, because a database query in codebehind has to be done, when a new listItem is selected. So, I need to use a servercontrol dropdownlist. Now to my problem:
1
1776
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" Runat=server DataValueField="UserName" DataTextField="UserName" DataSource='<%# GetUserList() %>'>
6
14315
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 table also contains a field for photographerID which is used to join the two tables. I'm having problems with populating a dropDownList using the complete set of photographerNames and IDs from the 'photographer' table but
6
1482
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 can add a "Select Item," but is that the correct way to do it? I don't want it to hit the database at all the first time the page loads. I have done everything through visual studio and was trying to see if I could do this with no code behind. ...
2
2341
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 formview opens. The user can then click "insert" or "update" to either create a new row or edit the existing row. This all works fine as long as I only use textboxes and checkboxes in my insertItemTemplate and editItemTemplate. What I would like...
0
1706
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 SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which...
1
1163
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 buildYearDDLs(ByVal c As Control) Dim objdr As Data.OracleClient.OracleDataReader = Nothing Dim objcnn As Data.OracleClient.OracleConnection = Nothing
0
10588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.