|
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 | This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 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
|
|
|
|
May 18th, 2006, 04:33 PM
|
Registered User
|
|
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
MySQL table not changing with Update in Gridview
I created a page to test the edit/update function of GridView with a MySQL database. The test page works correctly. When I attempt to apply the same code technique to the real page I need to use, the database does not change when I click Update in Edit mode. I've been over the code again and again and I can't figure out where I've gone wrong.
Below is my code for the page that doesnât work. Please help!
<html>
<head>
</head>
<body bgcolor="#53868b">
<center>
<form runat="server">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" AutoGenerateEditButton="true" Width="2000px" DataSourceID="SqlDataSource1" PageSize="20"><
FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White"/>
<RowStyle BackColor="#E3EAEB" />
<EditRowStyle BackColor="#FFCCCC" ForeColor="Black" Font-Bold="True" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="Botanical Name" DataField="Botanical_Name" SortExpression="Botanical_Name" ReadOnly="true" />
<asp:BoundField HeaderText="Common Name" DataField="Common_Name" SortExpression="Common_Name" ReadOnly="True" />
<asp:BoundField HeaderText="Order Date" DataField="Order_Date" SortExpression="Order_Date" HtmlEncode="False" DataFormatString="{0:d}" ReadOnly="True" />
<asp:BoundField HeaderText="Ordered By" DataField="Ordered_By" SortExpression="Ordered_By" ReadOnly="True" />
<asp:BoundField HeaderText="Size" DataField="Size" SortExpression="Size" />
<asp:BoundField HeaderText="Price" DataField="Price" SortExpression="Price" HtmlEncode="False" DataFormatString="{0:n5}" />
<asp:BoundField HeaderText="Quantity" DataField="Quantity" SortExpression="Quantity" HtmlEncode="False" DataFormatString="{0:n2}" />
<asp:BoundField HeaderText="Vendor" DataField="Vendor" SortExpression="Vendor" ReadOnly="True" />
<asp:BoundField HeaderText="PO" DataField="PO" SortExpression="PO" ReadOnly="true" />
<asp:BoundField HeaderText="Delivery Date" DataField="Delivery_Date" SortExpression="Delivery_Date" HtmlEncode="False" DataFormatString="{0:d}" />
<asp:BoundField HeaderText="Supplied By" DataField="Supplied_By" SortExpression="Supplied_By" />
<asp:BoundField HeaderText="Delivered By" DataField="Delivered_By" SortExpression="Delivered_By" />
<asp:BoundField HeaderText="Delivery Invoice" DataField="Delivery_Invoice" SortExpression="Delivery_Invoice" />
<asp:BoundField HeaderText="Shipping Cost for Entire Shipment" DataField="Shipping_Cost" SortExpression="Shipping_Cost" HtmlEncode="False" DataFormatString="{0:c2}" />
<asp:BoundField HeaderText="Total # of Plants in Shipment" DataField="NumberPlants" SortExpression="NumberPlants" HtmlEncode="False" DataFormatString="{0:n2}" />
<asp:BoundField HeaderText="Tag Cost for This Plant" DataField="Tag_Cost" SortExpression="Tag_Cost" HtmlEncode="False" DataFormatString="{0:c2}" />
<asp:BoundField HeaderText="Total Charge for This Plant" DataField="Total_Charge" SortExpression="Total_Charge" HtmlEncode="False" DataFormatString="{0:c2}" />
SelectCommand="SELECT * FROM paid ORDER BY Vendor, PO, Invoice"
UpdateCommand="UPDATE paid SET Size=?, Price=?, Quantity=?, Supplied_By=?, Delivered_By=?, Delivery_Invoice=?, Shipping_Cost=?, NumberPlants=?, Tag_Cost=?, Total_Charge=?, Vendor_Order=?, Invoice=?, Notes=? WHERE Botanical_Name=? AND PO=?">
<UpdateParameters>
<asp:Parameter Type="String" Name="Botanical_Name" />
<asp:Parameter Type="String" Name="Common_Name" />
<asp:Parameter Type="DateTime" Name="Order_Date" />
<asp:Parameter Type="String" Name="Ordered_By" />
<asp:Parameter Type="String" Name="Size" />
<asp:BoundField HeaderText="Vendor Order #" DataField="Vendor_Order" SortExpression="Vendor_Order" />
<asp:BoundField HeaderText="Invoice #" DataField="Invoice" SortExpression="Invoice" />
<asp:BoundField HeaderText="Notes" DataField="Notes" SortExpression="Notes" />
</Columns> </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:linersConnectionString %>" ProviderName="<%$ ConnectionStrings:linersConnectionString.ProviderN ame %>" <asp:Parameter Type="Double" Name="Price" Size="5" />
<asp:Parameter Type="Double" Name="Quantity" Size="2" />
<asp:Parameter Type="String" Name="Vendor" />
<asp:Parameter Type="String" Name="PO" />
<asp:Parameter Type="DateTime" Name="Delivery_Date" />
<asp:Parameter Type="String" Name="Supplied_By" />
<asp:Parameter Type="String" Name="Delivered_By" />
<asp:Parameter Type="String" Name="Delivery_Invoice" />
<asp:Parameter Type="Double" Name="Shipping_Cost" Size="2" />
<asp:Parameter Type="Double" Name="NumberPlants" Size="2" />
<asp:Parameter Type="Double" Name="Tag_Cost" Size="2" />
<asp:Parameter Type="Double" Name="Total_Charge" Size="2" />
<asp:Parameter Type="String" Name="Vendor_Order" />
<asp:Parameter Type="String" Name="Invoice" />
<asp:Parameter Type="String"[red] Name="Notes" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</center>
</body>
</html>
|
May 19th, 2006, 08:31 AM
|
Registered User
|
|
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In my attempt to make this more readable with the colors, the order of the code got changed, so here it is after a simple cut/paste.
Any help on this would be greatly appreciated.
<html>
<head>
</head>
<body bgcolor="#53868b">
<center>
<form runat="server">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" AutoGenerateEditButton="true" Width="2000px" DataSourceID="SqlDataSource1" PageSize="20">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#E3EAEB" />
<EditRowStyle BackColor="#FFCCCC" ForeColor="Black" Font-Bold="True" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="Botanical Name" DataField="Botanical_Name" SortExpression="Botanical_Name" ReadOnly="true"/>
<asp:BoundField HeaderText="Common Name" DataField="Common_Name" SortExpression="Common_Name" ReadOnly="True"/>
<asp:BoundField HeaderText="Order Date" DataField="Order_Date" SortExpression="Order_Date" HtmlEncode="False" DataFormatString="{0:d}" ReadOnly="True"/>
<asp:BoundField HeaderText="Ordered By" DataField="Ordered_By" SortExpression="Ordered_By" ReadOnly="True"/>
<asp:BoundField HeaderText="Size" DataField="Size" SortExpression="Size"/>
<asp:BoundField HeaderText="Price" DataField="Price" SortExpression="Price" HtmlEncode="False" DataFormatString="{0:n5}"/>
<asp:BoundField HeaderText="Quantity" DataField="Quantity" SortExpression="Quantity" HtmlEncode="False" DataFormatString="{0:n2}"/>
<asp:BoundField HeaderText="Vendor" DataField="Vendor" SortExpression="Vendor" ReadOnly="True"/>
<asp:BoundField HeaderText="PO" DataField="PO" SortExpression="PO" ReadOnly="true" />
<asp:BoundField HeaderText="Delivery Date" DataField="Delivery_Date" SortExpression="Delivery_Date" HtmlEncode="False" DataFormatString="{0:d}" />
<asp:BoundField HeaderText="Supplied By" DataField="Supplied_By" SortExpression="Supplied_By"/>
<asp:BoundField HeaderText="Delivered By" DataField="Delivered_By" SortExpression="Delivered_By"/>
<asp:BoundField HeaderText="Delivery Invoice" DataField="Delivery_Invoice" SortExpression="Delivery_Invoice"/>
<asp:BoundField HeaderText="Shipping Cost for Entire Shipment" DataField="Shipping_Cost" SortExpression="Shipping_Cost" HtmlEncode="False" DataFormatString="{0:c2}"/>
<asp:BoundField HeaderText="Total # of Plants in Shipment" DataField="NumberPlants" SortExpression="NumberPlants" HtmlEncode="False" DataFormatString="{0:n2}"/>
<asp:BoundField HeaderText="Tag Cost for This Plant" DataField="Tag_Cost" SortExpression="Tag_Cost" HtmlEncode="False" DataFormatString="{0:c2}"/>
<asp:BoundField HeaderText="Total Charge for This Plant" DataField="Total_Charge" SortExpression="Total_Charge" HtmlEncode="False" DataFormatString="{0:c2}"/>
<asp:BoundField HeaderText="Vendor Order #" DataField="Vendor_Order" SortExpression="Vendor_Order"/>
<asp:BoundField HeaderText="Invoice #" DataField="Invoice" SortExpression="Invoice"/>
<asp:BoundField HeaderText="Notes" DataField="Notes" SortExpression="Notes"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:linersConnectionString %>" ProviderName="<%$ ConnectionStrings:linersConnectionString.ProviderN ame %>"
SelectCommand="SELECT * FROM paid ORDER BY Vendor, PO, Invoice"
UpdateCommand="UPDATE paid SET Size=?, Price=?, Quantity=?, Supplied_By=?, Delivered_By=?, Delivery_Invoice=?, Shipping_Cost=?, NumberPlants=?, Tag_Cost=?, Total_Charge=?, Vendor_Order=?, Invoice=?, Notes=? WHERE Botanical_Name=? AND PO=?" CancelSelectOnNullParameter="false">
<UpdateParameters>
<asp:Parameter Type="String" Name="Botanical_Name" />
<asp:Parameter Type="String" Name="Common_Name" />
<asp:Parameter Type="DateTime" Name="Order_Date" />
<asp:Parameter Type="String" Name="Ordered_By" />
<asp:FormParameter Type="String" Name="Size"/>
<asp:FormParameter Type="Double" Name="Price" Size="5"/>
<asp:FormParameter Type="Double" Name="Quantity" Size="2"/>
<asp:Parameter Type="String" Name="Vendor" />
<asp:Parameter Type="String" Name="PO" />
<asp:Parameter Type="DateTime" Name="Delivery_Date"/>
<asp:FormParameter Type="String" Name="Supplied_By"/>
<asp:FormParameter Type="String" Name="Delivered_By"/>
<asp:FormParameter Type="String" Name="Delivery_Invoice"/>
<asp:FormParameter Type="Double" Name="Shipping_Cost" Size="2" />
<asp:FormParameter Type="Double" Name="NumberPlants" Size="2" />
<asp:FormParameter Type="Double" Name="Tag_Cost" Size="2" />
<asp:FormParameter Type="Double" Name="Total_Charge" Size="2" />
<asp:FormParameter Type="String" Name="Vendor_Order" />
<asp:FormParameter Type="String" Name="Invoice" />
<asp:FormParameter Type="String" Name="Notes" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</center>
</body>
</html>
|
|
|