SqlDataSource not getting update when using DataKeyNames

R

rlueneberg

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
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top