Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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
 
Old July 12th, 2006, 10:52 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default GridView not updating

I've been trying to update a gridview and am not successful. The delete command is working. This was created using VisualStudio 2005

I took out the updating of the date fields and just put in the description field to update to keep this as simple as possible.

The database is not being updated with the new value.

Any help would be much apprecited.
Here's the code

<asp:GridView ID="GridView1"
         runat="server"
         AutoGenerateColumns="False"
         DataSourceID="SqlDataSource1"
          Width="720px" DataKeyNames="ID">
             <Columns>

                 <asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID">
                     <EditItemTemplate>
                         <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="phase_description" SortExpression="phase_description">
                     <EditItemTemplate>
                         <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("phase_description") %>' AutoPostBack="true"></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label2" runat="server" Text='<%# Bind("phase_description") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="phase_begin_date" SortExpression="phase_begin_date">
                     <EditItemTemplate>
                         <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("phase_begin_date") %>' AutoPostBack="true"></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label3" runat="server" Text='<%# Bind("phase_begin_date") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="phase_end_date" SortExpression="phase_end_date">
                     <EditItemTemplate>
                         <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("phase_end_date") %>' AutoPostBack="true"></asp:TextBox>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label4" runat="server" Text='<%# Bind("phase_end_date") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
              <asp:CommandField ShowEditButton="True" />
              <asp:CommandField ShowDeleteButton="True" />
             </Columns>

        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:SurveyDatabaseConnectionString %>"
            ProviderName="<%$ ConnectionStrings:SurveyDatabaseConnectionString.P roviderName %>"
            SelectCommand="SELECT ID, phase_description, phase_begin_date, phase_end_date FROM Phase WHERE (fk_svy_id = ?)"
            UpdateCommand="UPDATE Phase SET phase_description = @phase_desription WHERE ID = @ID"
            DeleteCommand="DELETE FROM Phase WHERE ID = @ID">

            <SelectParameters>
                <asp:ControlParameter ControlID="SvyID" Name="fk_svy_id" PropertyName="Value" Type="Int32" />
            </SelectParameters>

           </asp:SqlDataSource>






Similar Threads
Thread Thread Starter Forum Replies Last Post
prob.with updating in gridview... knightmare102 ASP.NET 2.0 Professional 1 September 24th, 2007 08:52 AM
editing and updating a gridview sarah lee ASP.NET 2.0 Basics 2 December 22nd, 2006 05:45 AM
Gridview not updating database on Web Host jumpseatnews ASP.NET 2.0 Basics 3 February 2nd, 2006 10:54 PM
Gridview Checkbox Update not updating using Access AUhawk ASP.NET 2.0 Basics 0 October 27th, 2005 01:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.