Solved

Gridview Edit is not working

Posted on 2014-10-26
1
117 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 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

635 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