?
Solved

ASP.NET gridview Edit LinkButton

Posted on 2012-04-09
4
Medium Priority
?
460 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 2000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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