Solved

ObjectDataSource Delete Command Parameters

Posted on 2007-03-22
4
801 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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