all groups > dotnet ado.net > august 2004 >
You're in the

dotnet ado.net

group:

Updating a dataset from a datalist control


Updating a dataset from a datalist control ree32 NO[at]SPAM hotmail.com
8/31/2004 7:55:49 PM
dotnet ado.net: 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.

Re: Updating a dataset from a datalist control Scott M.
9/1/2004 12:33:27 AM
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.


[quoted text, click to view]

Re: Updating a dataset from a datalist control ree32 NO[at]SPAM hotmail.com
9/1/2004 7:59:02 PM
[quoted text, click to view]
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
Re: Updating a dataset from a datalist control Scott M.
9/1/2004 11:51:35 PM
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.


[quoted text, click to view]

Re: Updating a dataset from a datalist control ree32 NO[at]SPAM hotmail.com
9/5/2004 3:46:18 PM
[quoted text, click to view]

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
Re: Updating a dataset from a datalist control Scott M.
9/5/2004 10:38:50 PM
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.


[quoted text, click to view]

AddThis Social Bookmark Button