![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | GridView not Updating Through SqlDataSource I have a very simple setup that should work fine per documentation. However, my gridview control will not properly update using the updatecommand of the sqldatasource. I've simplified everything below. I'd like to be able to see a table of results in my gridview, click edit on any particular record, modify the data, then click update. What I find is happening is that my parameters are not being updated when I go into edit mode, change the text of the "firstName" field, and click update. In the OnUpdating method of the sqldatasource, I've stepped through the command parameters collection and it always contains the original values, not what I've typed into the editable textboxes in my grid. <asp:GridView ID="gvContacts" PageSize="200" DataKeyNames="id" CssClass="GridViewStyle" GridLines="both" AllowSorting="true" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True" Width="98%" Visible="true" > <Columns> <asp:BoundField DataField="firstName" HeaderText="First Name" SortExpression="firstName" HeaderStyle-HorizontalAlign="center" HeaderStyle-VerticalAlign="middle" > </asp:BoundField> <asp:CommandField ShowEditButton="true" ShowDeleteButton="true" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:MyConnectionString%>" SelectCommand="SELECT id, firstName, lastName, email, phone, importance, message, subscribeToNewsletter, howDidYouHearAboutUs, createdBy, dateCreated, lastUpdateBy, lastUpdateDate FROM Contacts"SelectCommandType="text" UpdateCommand = "UPDATE Contacts SET firstName=@firstName where id=@original_id" UpdateCommandType="text" DeleteCommand="DELETE FROM Contacts WHERE id=@original_id" DeleteCommandType="Text"> </asp:SqlDataSource> -- PK9 |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Sqldatasource Update | .NET General | |||
| VB.NET: dynamically change SqlDataSource SelectCommand and re-exec | .NET General | |||
| How to reset the SelectCommand of a SqlDataSource on the client(JavaScript)? | .NET General | |||
| newbie question on SqlDataSource object | .NET General | |||
| CTP Out-GridView | PowerShell | |||