Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Gridview Edit is not working

Posted on 2014-10-26
1
Medium Priority
?
121 Views
Last Modified: 2014-10-28
I have a gridview and when I click the update button nothing is happening.  I do not get an error.  I'm sure it is something simple, but I am missing it.


<asp:GridView ID="gvLocations" runat="server" AllowPaging="True" 
    AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" 
    DataSourceID="dsLocations" ForeColor="Black" GridLines="Vertical" 
        BackColor="White" BorderColor="#999999" BorderStyle="Solid" 
        BorderWidth="1px" AutoGenerateEditButton="True">
        <Columns>
            <asp:BoundField DataField="Location_Name" HeaderText="Location" 
                SortExpression="Location_Name" />
            <asp:BoundField DataField="Address1" HeaderText="Address1" 
                SortExpression="Address1" />
            <asp:BoundField DataField="Address2" HeaderText="Address2" 
                SortExpression="Address2" />
            <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
            <asp:BoundField DataField="StateAbbr" HeaderText="State" 
                SortExpression="StateAbbr" />
            <asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
            <asp:BoundField DataField="column1" HeaderText="Co-Op" 
                SortExpression="column1" />
            <asp:TemplateField HeaderText="Store Type " SortExpression="StoreTypeName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
                        DataSourceID="dsStoreType" DataTextField="StoreTypeName" 
                        DataValueField="StoreTypeID" SelectedValue='<%# Bind("StoreTypeID") %>'>
                        <asp:ListItem Selected="True" Value="">Select</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("StoreTypeName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="dsLocations" runat="server" 
        ConnectionString="<%$ ConnectionStrings:POSDataString %>" 
        
        SelectCommand="SELECT Locations.[Location Name] AS Location_Name, Locations.Address1, Locations.Address2, Locations.City, Locations.StateAbbr, Locations.Zip, Locations.[Co-Op] AS column1, Locations.StoreTypeID, StoreType.StoreTypeName FROM Locations LEFT OUTER JOIN StoreType ON Locations.StoreTypeID = StoreType.StoreTypeID" 
        
        UpdateCommand="UPDATE Locations SET Address1 = @Address1, Address2 = @Address2, City = @City, StateAbbr = @StateAbbr, Zip = @Zip, [Co-Op] = '[@Co-Op]', StoreTypeID = @StoreTypeId WHERE ([Location Name] = @LocationName)">
        <UpdateParameters>
            <asp:Parameter Name="Address1"/>
            <asp:Parameter Name="Address2"/>
            <asp:Parameter Name="City" Type="String"/>
            <asp:Parameter Name="StateAbbr" Type="String"/>
            <asp:Parameter Name="Zip" Type="String" />
            <asp:Parameter Name="StoreTypeId" Type="Int32" />
            <asp:Parameter Name="LocationName"/>
        </UpdateParameters>
    </asp:SqlDataSource>

Open in new window

0
Comment
Question by:rcowen00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 2000 total points
ID: 40406669
The very first thing I noticed is this:

'[@Co-Op]'

[Co-Op] = '[@Co-Op]'

Why????

Second, I don't see it declared in <Update Parameters>

I would try something like this:

[Co-Op] = @Co_Op

Then in update paramerts section I would have:

            <asp:Parameter Name="Co_Op" Type="String"/>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question