Solved

ObjectDataSource Delete Command Parameters

Posted on 2007-03-22
4
793 Views
Last Modified: 2011-09-20
I have a gridview thats datasource is an objectdatasource which has the following methods.

Select : return a DataSet //used to popluate from a sqlTable
              public static DataSet SelectDataset()
             {
                   //code to select DataSet
              }
Delete : Method with 1 parameter used to Identify the id
               public static void DeleteCommand(String id)
              {
                   //code to delete
               }

When the user clicks the Delete button the OnRowDeleting Event runs ...
Currently this errors out because the id value is never set before the DeleteCommand runs.

How do I  ....set the String id parameter.... to the value from the .....GridViewDeleteEventArgs RowIndex value.....?
0
Comment
Question by:Michael_R_Evans
  • 3
4 Comments
 
LVL 11

Expert Comment

by:lijunguo
ID: 18787845
Here is a good tutorial on GridView delete
http://www.codeproject.com/aspnet/GridViewConfirmDelete.asp
0
 

Author Comment

by:Michael_R_Evans
ID: 18793677
What I am looking for is a way ( if possible ) to set the parameters that are being used in the DeleteMethod that I created. Or if someone could explain to me how the GridView uses the ObjectDataSource to configure the parameters from the Method.
0
 
LVL 11

Accepted Solution

by:
lijunguo earned 500 total points
ID: 18796530
when you are deleting a record from a GV, there has to be a unique key for delete. Otherewise, how could a record being deleted instead of multiple record. So it's simple enough from GV to set a Datakey column.
0
 
LVL 11

Expert Comment

by:lijunguo
ID: 18796570
From GV set up DataKeyNames="column name", then following the first link I posted, you'll get there
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Execute Stored Procedure for a set of values 5 42
Cannot upload files above 1mb IIS7 11 39
asp.net mvc input file 2 32
SSRS ReportViewer report timeout 7 101
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now