Link to home
Start Free TrialLog in
Avatar of rcowen00
rcowen00Flag for United States of America

asked on

Gridview Edit is not working

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

ASKER CERTIFIED SOLUTION
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial