Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ObjectDataSource Delete Command Parameters

Posted on 2007-03-22
4
Medium Priority
?
812 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

772 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