Updating a dataset from a datalist control

  • Thread starter Thread starter ree32
  • Start date Start date
R

ree32

I am using the editItem templates of the datalist control. I have a
problem as to transferring the changes made by the user to the
dataset.

As I am reading the results form a database to a dataset then using
the dataset to fill the datalist.
The problem is I am not sure how to transfer changes back to the
dataset as I plan on using the update method of the dataset to change
the database.

Is this possible? or do I have to use the clumsy way of creating an
sql string command to update the changes back to the database.

Thanks
 
Your DataList has an eventhandler for updates made to it (UpdateCommand, I
think). In this eventhandler, you would change the row of the dataset that
corresponds to the row of the DataList being edited.

When you are ready to update the database, you use the Update method of the
DataAdapter (not the DataSet) and, of course, you need to have configured
the DataAdapter's update command before calling DataAdapter.update.
 
Scott M. said:
Your DataList has an eventhandler for updates made to it (UpdateCommand, I
think). In this eventhandler, you would change the row of the dataset that
corresponds to the row of the DataList being edited.

When you are ready to update the database, you use the Update method of the
DataAdapter (not the DataSet) and, of course, you need to have configured
the DataAdapter's update command before calling DataAdapter.update.
The problem is how do I get control of this dataadapter, as this
adapter is called in a separate function ( since this fuction is what
initially populates the datalist on the page before the user clicks an
edit button.
 
What do you mean "get control" of the DataAdapter. If it is declared at the
module level, you can work with it anywhere in your class.
 
Scott M. said:
What do you mean "get control" of the DataAdapter. If it is declared at the
module level, you can work with it anywhere in your class.

What do you mean by the module level. I am only declaring the dataset
in the sub. So when I finish with the sub I would not be able to get
control of the dataset?

Are you saying the dataset should be declared just inside the class
declaration with all the the other asp web controls such as as
buttons, dropdownlists?
 
Yes, that is sometimes referred to as module level.

If you declare something there, you can use it in any other subs/functions
of that class.
 
Back
Top