i am trying to update some records using the gridview. i have created my own updatecommand but the problem is that when i run this command in query builder it runsfine and update the desired recored but when i try to use it from the grid view, it doesnt update the record:
Code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="GridViewRetriefValues._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Style="left: 46px; position: relative; top: 22px"
Text="Show Records" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="CustomerID" DataMember="DefaultView" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None" Style="left: 140px; position: relative;
top: 33px" Visible="False" AllowSorting="True">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
<asp:CommandField ShowEditButton="True" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CustomerID], [CompanyName], [City], [PostalCode], [Country], [Phone] FROM [Customers] where country='uk' "
Updatecommand="UPDATE Customers SET CompanyName = @CompanyName, City = @City, PostalCode = @PostalCode, Country = @Country, Phone = @Phone WHERE (CustomerID = @orignal_CustomerID)">
<UpdateParameters >
<asp:Parameter Name= "Companyname" Type =String />
<asp:Parameter Name ="City" Type =String />
<asp:Parameter Name="PostalCode" />
<asp:Parameter Name ="Country" Type =String />
<asp:Parameter Name ="Phone" Type=String />
<asp:Parameter Name="orignal_Customerid" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:Label ID="Label1" runat="server" Style="left: 102px; position: relative; top: 75px"
Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Cheers
Sheraz