473,320 Members | 1,846 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,320 software developers and data experts.

Access GridView DataKeys on Delete

Hi There,

In binding my gridview i do this:

private void BindGrid(int month, int year)
{
BookingProvider provider = new BookingProvider();
DataTable dt = provider.GetMonthsEvent(month, year);
this.gridBookings.DataSource = dt;
this.gridBookings.DataKeyNames = new string[] { "Id" };
this.gridBookings.DataBind();
}

And when deleting a row after a delete command I do this

protected void gridBookings_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
BookingProvider provider = new BookingProvider();
provider.DeleteBooking((long)(e.Keys["Id"]));
}

How come it fails??? The keys collection is null?
Also e.RowIndex = the key of the row being deleted as per the database??
i.e. RowIndex = Key??
But the docs read like e.RowIndex is supposed to be the index of the row
according to the grid. i.e a grid with 6 rows I would have though the 6 th
row would have a row index of 5 (zero based)???

Thanks
Dec 12 '07 #1
0 1048

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

Similar topics

4
by: MasterChief | last post by:
I have a customer that likes the gridview but instead of using the standard Delete command for each row he wants to be able to put a checkbox next to the row so he can chose multiple records and...
1
by: cheloman12 | last post by:
Hi, I posted this problem some days ago. I repeat it because it was no answered. If description is confused, please make me know and i'll try to explain the case better. Thanks a lot, Marcelo...
1
by: Mike P | last post by:
When you use a SqlDataSource to hook up data to a GridView it seems to be to be very inflexible. For example, I want to create my own Delete button with my own code and I also want to create a...
2
by: Narshe | last post by:
I have a gridview with datakeyname="Id" that is using a sqldatasource. When I click delete on the gridview, the datakeys property is empty during the deleting event.
0
by: ssims | last post by:
I've got a GridView that's sorted by a stored procedure with ROW_NUMBER: PROCEDURE dbo.GetCalendarsByStatusIDPaged ( @startRowIndex int, @maximumRows int, @statusID int ) AS
4
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code...
9
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
0
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't...
2
by: Vajrala Narendra | last post by:
Hi, all am working on asp.net, c# 2.0 i want to delete a row from a grid view for that i take datakeyname inn gris view i wrote coding as <asp:GridView ID="GridView2" runat="server"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.