By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,717 Members | 2,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,717 IT Pros & Developers. It's quick & easy.

Dropdown database bound - simple screen with only dropdownbox, bestway to solve it [newby]

P: n/a

Since im quite new to ASP.NET i wanted to ask you folks what the best
way is to create a WebForm for modifying 1 field from a record. The
manipulation of this field can be done by using dropdown list.

Previously i've written a lot of these page's by not using the
webcontrols, but now i've reached this magically moment that i want to
try these features. :D

In short, the program exists of 1 table, called "details" and another,
which is called "lookup". The aspx page is started with the parameter
key. So the call will be the following:


My current code:
- Added OleDbConnection to the webform
- Connection String is retrieved from web.config (done by adjusting
dynamic properies)

- Added a DataAdapter (for the details table)
- Modified the SelectCommand in such a way that it needs an

- Added a DataAdapter (for the lookup table) (only select command)

- Generated a DataSet for both table's in DataDefinitions DataSet

- Added the DataDefinitions DataSet to the webform

- Added a dropdown to the webform
- DataMember = lookup
- DataSource = dataSet
- DataTextField = lookupfield
-SelectedValue = Simple Binding: dataSet -> Details -> [..] -> field

- Added a button to the form with the following code:

- Added a method PageLoad with the following code:
private void Page_Load(object sender, System.EventArgs e)
if(Request.Params["key"] == null)
throw new HttpException("Parameter 'key' is missing");
if (!this.IsPostBack )
{ oleDbSelectCommand.Parameters["key"].Value
= Request.Params["key"];
if(dataSet.Tables["details"].Rows.Count != 1) throw new
HttpException("Did not find 1 record for key:" + Request.Params["key"]);
- Value of the current value is not set in the dropdown list
- When i press the button, i dont have the any data in the dataset.

- What should i change in the current situation to make it work
- What is the -best- way to create such a page (sample's / pointers)
- Is it wise to use the databinding? Lots of examples use an iteration
to put the data in the dropdown box
- How do i close the window after is saved the data?

Eduard Witteveen
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.