468,242 Members | 1,599 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

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 1607
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 discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.