Hello,
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:
http://localhost/aspcontrols/DetailsEdit.aspx?key=1234
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
CommandParamete r.
- 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
Properties:
- DataMember = lookup
- DataSource = dataSet
- DataTextField = lookupfield
Databindings:
-SelectedValue = Simple Binding: dataSet -> Details -> [..] -> field
- Added a button to the form with the following code:
detailsDataAdap ter.Update(data Set);
- Added a method PageLoad with the following code:
private void Page_Load(objec t sender, System.EventArg s e)
{
if(Request.Para ms["key"] == null)
{
throw new HttpException(" Parameter 'key' is missing");
}
if (!this.IsPostBa ck )
{ oleDbSelectComm and.Parameters["key"].Value
= Request.Params["key"];
detailsDataAdap ter.Fill(dataSe t);
if(dataSet.Tabl es["details"].Rows.Count != 1) throw new
HttpException(" Did not find 1 record for key:" + Request.Params["key"]);
lookupDataAdapt er.Fill(dataSet );
dropdown.DataBi nd();
}
}
Problems:
=============== =
- 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.
Question:
=============== =
- 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