Using objectdatasource and automated updates: receiving wrong parameters.

C

craigkenisston

I have a grid attached to an objectdatasource from which just one field
is editable.
For the update method I have a method with two parameters, the key of
the record and the column to be updated.
However, what's happening is that I am receiving an empty key of the
record in my update method.

<asp:BoundField DataField="Key" HeaderText="Key" ReadOnly="True"
SortExpression="Key" />
<asp:BoundField DataField="AcceptReject" HeaderText="AcceptReject"
ReadOnly="False" SortExpression="AcceptReject" />

I notice that I I set Readonly False for the key expression, the
parameter is correctly received in the update method.
So, why should I have it editable in order to work ?
Is there any other way to take this parameters to the update method
without having to put my key in edit mode ?
 
S

S. Justin Gengo [MCP]

Craig,

Have you set the datakeynames property of the grid?

After setting it I retrieve my key from the gridview using the row's index:

Dim ItemId As Int32 =
CType(GridView1.DataKeys.Item(GridViewRow.RowIndex).Value, Int32)



--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top