473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ASP.NET 2.0 objectdatasource and datakeynames with gridview

So, I've bitten the bullet and am converting some of my asp.net 1.1
sites to asp.net 2.0, now after many issues I have come to a stop with
the objectdatasource and gridviews and maybe someone can help!

I have update, add adapter calls on the objectdatasource working well,
however I have an issue with the delete call.

In ASP.NET 2.0 I see that invisible columns are now no longer sent
across in viewstate (something about security) and this was my first
issue when converting, so I read a blog that the way to get round this
is to store the values in the datakeynames property of the grid, ok so
far!

In my gridview I have some dropdown lists in the edittemplate and
checkboxes which DONT store value information therefore things like
"isenabled" column from the database which will be displayed as a
checkbox I store in the datakeynames of the gridview which works fine
apart from when I call the delete method on a row.

My delete method has one parameter, the id of the row and this is
sufficient to delete, BUT because I have placed 3 other columns in the
datakeynames it now requires me to place these columns as parameters
in the delete method!!

I know I can do a workaround of having invisible labels in the
template columns or just create the method with these parameters but
is that really a solution?

Am I missing something, There is only 1 delete parameter in my
objectdatasource markup (see below) so why is it saying I need 4
parameters which cunningly enough is equal to the datakeynames I have
set

If anyone can help or shed some light I would be grateful

Many thanks

Richard

<asp:GridView ID="GridViewDetail" DataSourceID="ObjectDataSource1"
runat="server" AutoGenerateColumns="False"
DataKeyNames="PId,PSpecial,PBillable,PStatus" PageSize="100"
OnRowDataBound="GridViewDetail_RowDataBound" ShowFooter="True"
OnRowCommand="GridViewDetail_RowCommand"
OnRowUpdating="GridViewDetail_RowUpdating"
CssClass="subcostsfullspan">
<Columns>
<Columns.....>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetProducts"

TypeName="xxx.LifeStyleSystem.BusinessLayer.Search .ProductManager"
UpdateMethod="UpdateProduct" DeleteMethod="DeleteProduct">
<UpdateParameters>
<asp:Parameter Name="PId" Type="Int64" />
<asp:Parameter Name="PCostString" Type="String" />
<asp:Parameter Name="PDescription" Type="String" />
<asp:Parameter Name="PGross" Type="Decimal" />
<asp:Parameter Name="PSpecial" Type="Boolean" />
<asp:Parameter Name="PStatus" Type="Int32" />
<asp:Parameter Name="PBillable" Type="Boolean" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="PdId" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>

Oct 2 '07 #1
2 3218
Try adding this tho your Deleting method of your datasource.

e.InputParameters.RemoveAt(1)
e.InputParameters.RemoveAt(2)
e.InputParameters.RemoveAt(3)
TP

Oct 3 '07 #2
On 3 Oct, 20:02, wcs...@gmail.com wrote:
Try adding this tho your Deleting method of your datasource.

e.InputParameters.RemoveAt(1)
e.InputParameters.RemoveAt(2)
e.InputParameters.RemoveAt(3)

TP
Many thanks, I placed this in the ObjectDataSource.Deleting event and
actually did this:

e.InputParameters.RemoveAt(1)
e.InputParameters.RemoveAt(2)
e.InputParameters.RemoveAt(3)

because as the parameters are removed it reindexes!

Again many thanks

Richard

Oct 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
4
by: Anne Catterick | last post by:
Hi, I have an british ASP.Net 2.0 application which is doing what (should) be very simple. But I am having issues. On my page I have a GridView as follows (some tags excluded for easy...
3
by: mthomason | last post by:
I keep getting this error when trying to update records using an ObjectDataSource. I have seen others post similar errors...but I haven't found any solutions. ObjectDataSource...
2
by: Damon | last post by:
Help! Need this fixed ASAP. I have a GridView/DetailsView master/details form set up, with both bound to separate ObjectDataSource objects. Both the GridView and the DetailsView have a...
1
by: Raja | last post by:
Hi Everybody Just playing with ObjectDataSource and noticed the following. I have a Gridview which binds to a ObjectDataSource. ObjectDataSource gets data from a typed dataset created with VWD. In...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
0
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check...
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
0
by: Cirene | last post by:
Using Visual Studio I created a DataSet using the GUI (XSD file). Trying to use a tiered methodology I called the functions from my BLL. Namespace Zzz.BusinessLogicLayer #Region "DAL Access"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.