UpdateQuery problem

E

etam

Hi,

I am trying to build updateable GridView. I can't see the problem with
this code but it simply doesnt update the DataSet.

It doesnt work with or without
'OldValuesParameterFormatString="original_{0}"'.

It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
think that problem is with @original_value, it is problably empty...
Do you know why?

<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField
DataField="id"
HeaderText="id"
InsertVisible="False"
ReadOnly="True"
SortExpression="id" />
<asp:BoundField
DataField="topic"
HeaderText="topic"
SortExpression="topic" />
</Columns>
</asp:GridView>

<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:projectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:parameter Name="topic" Type="String" />
<asp:parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance,
Etam.
 
E

etam

You would have to change the parameter to ID also. I assume that ID is a
primary key?

Finally! <asp:parameter Name="original_id" Type="Int64" /> works! It
was 32 :/.
Thanks for help!
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top