 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 18th, 2008, 10:31 AM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DetailsView update not working.
Hi all,
I have a detailsview that I am trying to implement update functionality, but am having some issues:
Here's the code:
Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:relOUPConnectionString %>"
SelectCommand="SELECT * FROM [OUP_SAPData]" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"
UpdateCommand="UPDATE [OUP_SAPData] SET [JobNo] = @JobNo, [GL_AccCode] = @GL_AccCode,
[CostCentre] = @CostCentre,
[SAPFirstCostOrderNo] = @SAPFirstCostOrderNo,
[ISBN] = @ISBN, [SAPPONum] = @SAPPONum,
[POConditionType] = @POConditionType
WHERE [ID] = @original_ID AND
[JobNo] = @original_JobNo AND
[GL_AccCode] = @original_GL_AccCode AND
[CostCentre] = @original_CostCentre AND
[SAPFirstCostOrderNo] = @original_SAPFirstCostOrderNo AND
[ISBN] = @original_ISBN AND
[SAPPONum] = @original_SAPPONum AND
[POConditionType] = @original_POConditionType">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_JobNo" Type="String" />
<asp:Parameter Name="original_GL_AccCode" Type="String" />
<asp:Parameter Name="original_CostCentre" Type="String" />
<asp:Parameter Name="original_SAPFirstCostOrderNo" Type="String" />
<asp:Parameter Name="original_ISBN" Type="String" />
<asp:Parameter Name="original_SAPPONum" Type="String" />
<asp:Parameter Name="original_POConditionType" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="JobNo" Type="String" />
<asp:Parameter Name="GL_AccCode" Type="String" />
<asp:Parameter Name="CostCentre" Type="String" />
<asp:Parameter Name="SAPFirstCostOrderNo" Type="String" />
<asp:Parameter Name="ISBN" Type="String" />
<asp:Parameter Name="SAPPONum" Type="String" />
<asp:Parameter Name="POConditionType" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_JobNo" Type="String" />
<asp:Parameter Name="original_GL_AccCode" Type="String" />
<asp:Parameter Name="original_CostCentre" Type="String" />
<asp:Parameter Name="original_SAPFirstCostOrderNo" Type="String" />
<asp:Parameter Name="original_ISBN" Type="String" />
<asp:Parameter Name="original_SAPPONum" Type="String" />
<asp:Parameter Name="original_POConditionType" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="JobNo" Type="String" />
<asp:Parameter Name="GL_AccCode" Type="String" />
<asp:Parameter Name="CostCentre" Type="String" />
<asp:Parameter Name="SAPFirstCostOrderNo" Type="String" />
<asp:Parameter Name="ISBN" Type="String" />
<asp:Parameter Name="SAPPONum" Type="String" />
<asp:Parameter Name="POConditionType" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
Now I can't see what i'm missing here. Any thoughts?
|
|

April 18th, 2008, 10:58 AM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I get no errors, it returns to the page as expected, but doesn't update the details.
|
|

April 19th, 2008, 07:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Andew,
Difficult to tell without the ability to try it out, or seeing other parts of your code.
Maybe the error is caused by the ConflictDetection? Maybe some fields are null, or get lost when the DetailsView posts back so the WHERE clause never finds the right record to update? To see if that's the problem, change the WHERE to:
WHERE [ID] = @original_ID
Also, make sure the DetailsView is set up correctly and uses the right keys and columns.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
|
|

April 22nd, 2008, 10:17 AM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Found the problem.
The reason it wasn't updating the entry was that in the DetailsView, I wasn't displaying the id (primary key) so the row in the table wasn't updating.
Do you know of any way to be able to update the row without having to display the id? It's not a major issue, I just would rather not have to show it...
Cheers for your help.
|
|

April 22nd, 2008, 11:23 AM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No I haven't....yet!
Will look that up and keep you posted, cheers!
|
|
 |