Solved

ASP.NET gridview Edit LinkButton

Posted on 2012-04-09
4
459 Views
Last Modified: 2012-04-13
I have a GridView that has a Delete and Edit LinkButtons at the end of every row.  What I want to get accomplished is that when the user clicks the Edit LinkButton, that they will then be able to edit any of the values in the selected row they chose to Edit, and then the Edit LinkButton will then read "Update" and when the user clicks Update it will execute the UPDATE statement on the DataSource that is specified for the GridView
0
Comment
Question by:zintech
[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
4 Comments
 

Author Comment

by:zintech
ID: 37823115
Here is the code for the GridView right now.  Nothing happens when I click the Edit LinkButton.

<asp:GridView ID="GridView1" runat="server" oreColor="#333333" AutoGenerateColumns="False"
            DataKeyNames="Id" DataSourceID="DataSource1"
            EnableModelValidation="True" AllowSorting="True" Width="468px"
            onrowdatabound="GridView1_RowDataBound">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
                    ReadOnly="True" SortExpression="Id" Visible="False" />
                <asp:BoundField DataField="ProjectId" HeaderText="ProjectId"
                    SortExpression="ProjectId" Visible="False" />
                <asp:BoundField DataField="VersionId" HeaderText="VersionId"
                    SortExpression="VersionId" Visible="False" />
                <asp:BoundField DataField="WBS" HeaderText="WBS" ItemStyle-Wrap="false"
                    SortExpression="WBS" />
                <asp:BoundField DataField="WBSTitle" HeaderText="WBSTitle" ItemStyle-Wrap="false"
                    SortExpression="WBSTitle" />
            <asp:TemplateField ItemStyle-Wrap="false">
                    <ItemTemplate>
                            <asp:LinkButton ID="LinkButtonDelete" CausesValidation="false" CommandName="Delete" Text="Delete" runat="server"></asp:LinkButton>
                            <asp:linkbutton id="btnEdit" runat="server" commandname="Edit" text="Edit" />  
                    </ItemTemplate>
                     <edititemtemplate>  
                                        <asp:linkbutton id="btnUpdate" runat="server" commandname="Update"
 text="Update" />  
                                        <asp:linkbutton id="btnCancel" runat="server" commandname="Cancel"
 text="Cancel" />  
                                </edititemtemplate>
                </asp:TemplateField>
            </Columns>
             <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                      <PagerStyle HorizontalAlign="Center" BackColor="#284775" ForeColor="White" />
                                                      <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                                      <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                      <EditRowStyle BackColor="#999999" />
                                                      <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 37823199
This is a common requirement of a GridView. There are tons of examples online for the proper way to set up that functionality. You are primarily missing the event handlers for OnRowEditing, OnRowUpdating, etc. Look here:

http://devilswork.wordpress.com/2009/03/27/gridview-row-edit-delete-and-update/
0
 
LVL 5

Expert Comment

by:Vishal Kedar
ID: 37826463
0
 
LVL 8

Accepted Solution

by:
Ashutosh Vyas earned 500 total points
ID: 37826505
http://aspsnippets.com/Articles/GridView---Add-Edit-Update-Delete-and-Paging-the-AJAX-way.aspx

This also explains you a way to insert new records to the same grid
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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