![]() |
|
|
|
#1 |
|
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 SelectCommand="SELECT id, topic FROM Projects" UpdateCommand="UPDATE Projects SET topic = @topic WHERE (id = @original_id)" OldValuesParameterFormatString="original_{0}"> <UpdateParameters> <asp <asp </UpdateParameters> </asp:SqlDataSource> Thanks in advance, Etam. etam |
|
|
|
|
#2 |
|
Posts: n/a
|
Shouldn't it be "WHERE ID = @ID" ?
Try it. Peter -- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net "etam" wrote: > 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 > SelectCommand="SELECT id, topic FROM Projects" > UpdateCommand="UPDATE Projects SET topic = @topic WHERE > (id = @original_id)" > OldValuesParameterFormatString="original_{0}"> > <UpdateParameters> > <asp > <asp > </UpdateParameters> > </asp:SqlDataSource> > > Thanks in advance, > Etam. > > =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?= |
|
|
|
#3 |
|
Posts: n/a
|
On 21 Maj, 00:43, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.com> wrote: > Shouldn't it be "WHERE ID = @ID" ? > Try it. > Peter > -- > Site: http://www.eggheadcafe.com > UnBlog: http://petesbloggerama.blogspot.com > Short urls & more: http://ittyurl.net > > "etam" wrote: > > 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 > > SelectCommand="SELECT id, topic FROM Projects" > > UpdateCommand="UPDATE Projects SET topic = @topic WHERE > > (id = @original_id)" > > OldValuesParameterFormatString="original_{0}"> > > <UpdateParameters> > > <asp > > <asp > > </UpdateParameters> > > </asp:SqlDataSource> > > > Thanks in advance, > > Etam. Nope etam |
|
|
|
#4 |
|
Posts: n/a
|
You would have to change the parameter to ID also. I assume that ID is a
primary key? -- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net "etam" wrote: > On 21 Maj, 00:43, Peter Bromberg [C# MVP] > <pbromb...@yahoo.yabbadabbadoo.com> wrote: > > Shouldn't it be "WHERE ID = @ID" ? > > Try it. > > Peter > > -- > > Site: http://www.eggheadcafe.com > > UnBlog: http://petesbloggerama.blogspot.com > > Short urls & more: http://ittyurl.net > > > > "etam" wrote: > > > 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 > > > SelectCommand="SELECT id, topic FROM Projects" > > > UpdateCommand="UPDATE Projects SET topic = @topic WHERE > > > (id = @original_id)" > > > OldValuesParameterFormatString="original_{0}"> > > > <UpdateParameters> > > > <asp > > > <asp > > > </UpdateParameters> > > > </asp:SqlDataSource> > > > > > Thanks in advance, > > > Etam. > > Nope > > =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?= |
|
|
|
#5 |
|
Posts: n/a
|
On 21 Maj, 15:27, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.com> wrote: > You would have to change the parameter to ID also. I assume that ID is a > primary key? > -- > Site: http://www.eggheadcafe.com > UnBlog: http://petesbloggerama.blogspot.com > Short urls & more: http://ittyurl.net > > "etam" wrote: > > On 21 Maj, 00:43, Peter Bromberg [C# MVP] > > <pbromb...@yahoo.yabbadabbadoo.com> wrote: > > > Shouldn't it be "WHERE ID = @ID" ? > > > Try it. > > > Peter > > > -- > > > Site: http://www.eggheadcafe.com > > > UnBlog: http://petesbloggerama.blogspot.com > > > Short urls & more: http://ittyurl.net > > > > "etam" wrote: > > > > 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 > > > > SelectCommand="SELECT id, topic FROM Projects" > > > > UpdateCommand="UPDATE Projects SET topic = @topic WHERE > > > > (id = @original_id)" > > > > OldValuesParameterFormatString="original_{0}"> > > > > <UpdateParameters> > > > > <asp > > > > <asp > > > > </UpdateParameters> > > > > </asp:SqlDataSource> > > > > > Thanks in advance, > > > > Etam. > > > Nope Finally! <asp was 32 :/. Thanks for help! etam |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dial Up Problem | smackedass | A+ Certification | 3 | 02-02-2007 11:59 PM |
| Re: Virus Problem ** Help!** | David BlandIII | A+ Certification | 1 | 03-02-2004 06:00 PM |
| Pioneer DVR3100S problem with Satellite receiver Samsung DCR 9500 | Fredrik Bengtsson | DVD Video | 0 | 12-12-2003 02:32 PM |
| Re: Serious Computer Problem | hootnholler | A+ Certification | 1 | 11-24-2003 12:18 PM |
| Re: Serious Computer Problem | Bret | A+ Certification | 0 | 11-19-2003 12:51 AM |