473,320 Members | 1,612 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.

SqlDataSource not getting update when using DataKeyNames

I am having problem updating the value of a texbox control inside a
gridview in which its bound field is also specified in DataKeyNames.
What I noticed is that If I remove accountid from DatakeyNames the
update works automatically with no code. So, now what I am trying to
do is to programatically update the database to overwrite the value of
the DatakeyName using the code below, but it seems that SqlDatasource
is ignoring it. Can someone confirm if DataKeyNames are supposed to be
used only with Databound fields and for Asp.net "zero code"? The
problem is I still need the datakeyName in other events, unless someone
can point out other ways to access the gridview datasource in form of a
dataview, for example....

protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
SqlDataSource1.UpdateParameters["accountid"].DefaultValue =
e.NewValues["accountid"].ToString();

}

Rod

Feb 10 '06 #1
1 1734
After some pain. I Found the answer reading this article.

I just had to use different names for my Stored Procedure parameters.
The default update will match any parameters with an exact match of a
field that exists in sqldatasoruce. And it works now..

http://www.whitworth.org/Blog/Syndic...me=Development

Rod

Feb 13 '06 #2

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

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
2
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them...
3
by: Ken Cox [Microsoft MVP] | last post by:
I've been going around and around on this one. I can't believe that it is "by design" as Microsoft says. Here's the situation: In *declarative* syntax, I'm trying to create a default datetime...
0
by: =?Utf-8?B?UEs5?= | last post by:
I have a very simple setup that should work fine per documentation. However, my gridview control will not properly update using the updatecommand of the sqldatasource. I've simplified everything...
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: 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...
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: 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: 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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.