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?