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

Problem with GridView

Hello,
I'm having a strange problem with gridview, I have a portion of code that
binds data to the gridview:

gvCategories.DataSource = dt
gvCategories.DataKeyNames = New String() {"id_category"}
gvCategories.DataBind()

and I have a RowDeleting event handler that does the following:

#1 Dim id_category As Integer =
CInt(gvCategories.DataKeys(e.RowIndex).Value)
#2 CType(Session("GamesXCategories"),
GamesDS.GamesXCategoriesDataTable).FindByid_gameid _category(id_game,
id_category).Delete()

it was working very good before, but now I get an error in the line #1, the
error is "Index was out of range. Must be non-negative and less than the
size of the collection."

I don't understand what is happening...... it was working before, I put a
breakpoint on line #1 and I check, there is rows in the grid view....

thanks in advance!

Bruno
Mar 14 '06 #1
1 1860
DataKeyNames is a string where multiple key fields would be separated by
commas. It should be

gvCategories.DataKeyNames = "id_category"

--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"Bruno Piovan" <brunopiovan AT gmail DOT COM - NO SPAM> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Hello,
I'm having a strange problem with gridview, I have a portion of code that
binds data to the gridview:

gvCategories.DataSource = dt
gvCategories.DataKeyNames = New String() {"id_category"}
gvCategories.DataBind()

and I have a RowDeleting event handler that does the following:

#1 Dim id_category As Integer =
CInt(gvCategories.DataKeys(e.RowIndex).Value)
#2 CType(Session("GamesXCategories"),
GamesDS.GamesXCategoriesDataTable).FindByid_gameid _category(id_game,
id_category).Delete()

it was working very good before, but now I get an error in the line #1,
the error is "Index was out of range. Must be non-negative and less than
the size of the collection."

I don't understand what is happening...... it was working before, I put a
breakpoint on line #1 and I check, there is rows in the grid view....

thanks in advance!

Bruno

Mar 23 '06 #2

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

Similar topics

4
by: ber.janssens | last post by:
Hi, In ASP.NET 2.0, I have a GridView with 2 CommandFields, how can I determine in the SelectedIndexChanged event which CommandField is clicked? <asp:GridView ID="gvOrderList" runat="server"...
2
by: Loading name... | last post by:
Hey asp.net 2.0 I have a GridView on my webpage. This GridView's datasource is a SqlDataSource. The SqlDataSource returns 3 columns. Here is my problem: My GridView consist of 3 columns...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
6
by: Greg | last post by:
Hello, I have a GridView bound to a custom object. I set the DataKeyNames property along with the column DataField properties at design time, and bind the GridView to my object at run-time. In...
8
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I am trying to get a list of files from a specified directory using the System.IO namespace classes, and then use that list as the datasource for a GridView. I have been able to do this...
1
by: Jeff | last post by:
ASP.NET 2.0 I've got problems with the right column in my GridView. The GridView consist of 2 columns, the problem column is the column on the right side. The problem is that it looks like...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
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: Jeff | last post by:
hi there ;) asp.net 2.0 I'm having problem with paging in GridView, I'm using custom paging. The ObjectDataSource reads in the rows needed for displaying each page as each page is selected....
0
by: cmrhema | last post by:
Hi, I have a gridview problem while binding more than two gridviews. I am giving a sample scenario of what I have done so far I have two tables First table: Department , having columns...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.