简体   繁体   中英

Edit and update gridview rows on mouse click event

I want to edit and update gridview rows on mouse click event. If the user clicks on a row it should become editable and when he again clicks on the same row it should become uneditable and the changes should be saved.

my gridview looks like:-

<asp:GridView ID="grdexcelsheet" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" RowStyle-HorizontalAlign="Left" HorizontalAlign="Center"
                onpageindexchanging="grdexcelsheet_PageIndexChanging" 
                Width = "100%" Height = "100%" Font-Size="Small">
                <PagerSettings Position="Bottom" Mode="NextPreviousFirstLast"  FirstPageText="First" 
                     LastPageText="Last"  NextPageText="Next" PreviousPageText="Prev" PageButtonCount="5" />
                <Columns>
                <asp:BoundField DataField="SrNo" HeaderText="SrNo" ReadOnly="true" />
                <asp:TemplateField HeaderText="CustomerFieldName">
                        <ItemTemplate>
                            <asp:Label ID="Label4" Runat="server" Text='<%# Bind("CustomerFieldName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("CustomerFieldName") %>'>
                        </asp:TextBox>
                        </EditItemTemplate>
                     </asp:TemplateField>
                     <asp:BoundField DataField="CompanyFieldName" HeaderText="CompanyFieldName" ReadOnly="true" />
                     <asp:BoundField DataField="Usage" HeaderText="Usage" ReadOnly="true" />
                </Columns>
            </asp:GridView>

There are many ways to do this. You can use AJAX Control Toolkit Modal Popup Extender for updating your grid. Also, you can make use Update Panel from the same toolkit.

If you are willing to use third party controls...please use this which will be very to use

http://obout.com/grid/grid_commands.aspx ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM