Solved

ObjectDataSource Delete Command Parameters

Posted on 2007-03-22
4
788 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
Comment Utility
Here is a good tutorial on GridView delete
http://www.codeproject.com/aspnet/GridViewConfirmDelete.asp
0
 

Author Comment

by:Michael_R_Evans
Comment Utility
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
Comment Utility
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
Comment Utility
From GV set up DataKeyNames="column name", then following the first link I posted, you'll get there
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

13 Experts available now in Live!

Get 1:1 Help Now