View Single Post
  #3 (permalink)  
Old January 11th, 2007, 10:34 AM
Asp.Net Asp.Net is offline
Authorized User
Points: 176, Level: 3
Points: 176, Level: 3 Points: 176, Level: 3 Points: 176, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the answer :))
The working example is here:http://aspspider.biz/chadfunk/SqlDat...ataUpdate.aspx

(Be aware)Due to the often server crashes, you may receive Errors.
If you get error, come back later.
(Server Crashes cause Connection string failure)
================================================== ===================
Page 363
Listing 11-22 to 11-27

//-------------------------------------------------
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT * FROM [Customers]"
             UpdateCommand ="UPDATE [Customers] SET
                                     [CompanyName] = @CompanyName,
                                     [ContactName] = @ContactName,
                                     [ContactTitle] = @ContactTitle,
                                     [Address] = @Address,
                                     [City] = @City,
                                     [Region] = @Region,
                                     [PostalCode] = @PostalCode,
                                     [Country] = @Country,
                                     [Phone] = @Phone,
                                     [Fax] = @Fax
                                    WHERE [CustomerID] = @CustomerID
                            ">
                            
                             <UpdateParameters>
                                    <asp:Parameter Type ="string" Name ="CompanyName" Direction ="Input"/>
                                    <asp:Parameter Type ="string" Name ="ContactName" />
                                    <asp:Parameter Type ="string" Name ="ContactTitle" />
                                    <asp:Parameter Type ="string" Name ="Address" />
                                    <asp:Parameter Type ="string" Name ="City" />
                                    <asp:Parameter Type ="string" Name ="Region" />
                                    <asp:Parameter Type ="string" Name ="PostalCode" />
                                    <asp:Parameter Type ="string" Name ="Country" />
                                    <asp:Parameter Type ="string" Name ="Phone" />
                                    <asp:Parameter Type ="string" Name ="Fax" />
                                    <asp:Parameter Type ="string" Name ="CustomerID" />
                             </UpdateParameters>
            </asp:SqlDataSource>

------------

Gridview Code

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" Font-Names="Verdana" Font-Size="8.5pt">
            <Columns>
            <asp:CommandField ShowHeader ="True" HeaderText ="Command" ShowEditButton ="True" />
                <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly ="True" SortExpression="CustomerID" />
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
                <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" />
                <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
                <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:BoundField DataField="Fax" HeaderText="Fax" SortExpression="Fax" />
            </Columns>
        </asp:GridView>


/------------------------------------------------------------------
It works 100% :))