Solved

VB.NET Update, Delete Gridview with ObjectDataSource

Posted on 2014-09-10
5
635 Views
Last Modified: 2014-09-15
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?
0
Comment
Question by:schwientekd
  • 4
5 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40315261
can you provide what errors you are receiving ?
0
 

Author Comment

by:schwientekd
ID: 40315414
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.
0
 

Author Comment

by:schwientekd
ID: 40315532
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.
0
 

Accepted Solution

by:
schwientekd earned 0 total points
ID: 40316081
I found that my solution was that I needed to use the parameter @original_ID rather than just @ID.  Visual Studio apparently was looking for @original_ID.
0
 

Author Closing Comment

by:schwientekd
ID: 40322687
I found the solution myself.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
VB.NET 2008 Winforms Signing 13 31
Iteration Help (Asp.net VB) 5 24
SSRS 2016 Rendering HTML tables 3 26
New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question