473,320 Members | 2,024 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.

BaseDataList.DataKeys

Can anybody help me with BaseDataList.DataKeys?
I always get this error: Exception Details:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name:
index.
May be there is some demo about how to use it?
Nov 18 '05 #1
2 1578
Maybe it would help if you showed us how you were currently using it.

Basically the datakeys are stored in a DataKey collection, and you typically
access the key for the row being edited via:

dim key as integer = cint(YourLIstID.DataKeys(e.Item.ItemIndex))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Dave" <da*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Can anybody help me with BaseDataList.DataKeys?
I always get this error: Exception Details:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name:
index.
May be there is some demo about how to use it?

Nov 18 '05 #2
You might want to try this first -- the sample code on MSDN is wrong in that
it leaves out a key bit: You have to explicitly assign a key field prior to
binding to the datagrid, even though the dataset may appear to have already
assigned it for you.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SQLDataAdapter1.Fill(DataSet1)
If Not IsPostBack Then
DataGrid1.DataKeyField() = "MyPrimaryKeyFieldName"
DataGrid1.DataBind()
End If
End Sub
"Karl" wrote:
Maybe it would help if you showed us how you were currently using it.

Basically the datakeys are stored in a DataKey collection, and you typically
access the key for the row being edited via:

dim key as integer = cint(YourLIstID.DataKeys(e.Item.ItemIndex))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Dave" <da*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Can anybody help me with BaseDataList.DataKeys?
I always get this error: Exception Details:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name:
index.
May be there is some demo about how to use it?


Nov 18 '05 #3

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

Similar topics

4
by: Marina | last post by:
Hi, There is a component that is binding the results of a search to a DataList. By clicking on an image in the datalist, the user can download that particular item. We are using the DataKeys...
0
by: Alex | last post by:
Howcan I assign the DataKeys property of the datagrid programatically from a datasource not using the property builder? E.g. Data_grid1.DataKeys = ???? a column from the dataset?
0
by: Lingo | last post by:
I'm using beta2. I'm trying to create a gridview dynamically with a passed in SQL statement, everything works paging, sorting, and adding columns dynamically with the code. Because the hidden...
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.
2
by: cmay | last post by:
I am binding a List(Of T) to a DataList. In this case, T is a class Test, which has a property TestId. I am trying to use the DataKeyField with this <asp:DataList DataKeyField="TestId" ... ...
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...
0
by: Benton | last post by:
Hi there, I have a GridView with DataKeyNames="SID" on the markup. To me surprise, I can get this value just fine in the RowDeleting and RowEditing events, for instance: string pk =...
1
by: teju | last post by:
Hello, I have two datakeys defined in the grid view. I want to access the both the datakeys when u click a button. Iam able to access one of the datakeys but not the other. Below is the code ...
0
by: =?Utf-8?B?cmxt?= | last post by:
I have a gridview updating every 5 seconds. There are several DataKeys declared which I access successfully in the RowDataBound event. However, in the ROwCommand event the count of the DataKeys...
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
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: 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.