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
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