schwientekd
asked on
VB.NET Update, Delete Gridview with ObjectDataSource
I am trying to figure out how to update a gridview on my webpage which is bound to an ObjectDataSource. I have loaded the gridview based on a parameter to filter the results but I cannot figure out how to get the UPDATE and DELETE commands to work. When I go through the configure data source wizard for the ObjectDataSource I see where I can specify a method for UPDATE and DELETE. I have created UPDATE and DELETE methods in the dataset designer using both SQL and stored procedure but I get errors.
Can anyone give me some direction as to what I should be doing differently or what I need to look at to get the methods to work?
Can anyone give me some direction as to what I should be doing differently or what I need to look at to get the methods to work?
can you provide what errors you are receiving ?
ASKER
Example 1:
I selected one of the auto-generated UPDATE methods that were created with the dataset. In the wizard where I have the option to choose an update method it is listed as "Update(tablenameDateTable ), returns Int32". Using this method I get the error "Could not find a property named 'Column1' on the type specified by the DataObjectTypeName property in ObjectDataSource 'odsTableName'. Column1 is the first column listed in the gridview that I want to update in the table.
Example 2:
I selected "Update(DataRow dataRow) returns Int32" for the method and the error message I get from that one is "No parameterless constructor defined for this object".
Should I be doing something in the code behind file to update the gridview? It looks like this functionality is built-in to visual studio.
I selected one of the auto-generated UPDATE methods that were created with the dataset. In the wizard where I have the option to choose an update method it is listed as "Update(tablenameDateTable
Example 2:
I selected "Update(DataRow dataRow) returns Int32" for the method and the error message I get from that one is "No parameterless constructor defined for this object".
Should I be doing something in the code behind file to update the gridview? It looks like this functionality is built-in to visual studio.
ASKER
I also tried using an update method that I created in the dataset (called UpdateMethod).
UPDATE Table SET var1 = @var1, var2 = @var2 WHERE ID = @ID
When I use this Update method in the ObjectDataSource I get an error "ObjectDataSource 'ods1' could not find a non-generic method 'UpdateMethod' that has parameters: var1, var2, original_ID.
I can't seem to pass the parameters of the gridview row to the update method.
UPDATE Table SET var1 = @var1, var2 = @var2 WHERE ID = @ID
When I use this Update method in the ObjectDataSource I get an error "ObjectDataSource 'ods1' could not find a non-generic method 'UpdateMethod' that has parameters: var1, var2, original_ID.
I can't seem to pass the parameters of the gridview row to the update method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found the solution myself.