在鼠标单击事件上编辑和更新gridview行

时间:2012-02-22 12:30:58

标签: c# asp.net .net

我想在鼠标点击事件上编辑和更新gridview行。如果用户点击一行,它就会变得可编辑,当他再次点击同一行时,它应该变为不可编辑,并且应该保存更改。

我的gridview看起来像: -

<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>

2 个答案:

答案 0 :(得分:0)

有很多方法可以做到这一点。您可以使用AJAX Control Toolkit Modal Popup Extender更新网格。此外,您可以使用同一工具包中的更新面板。

答案 1 :(得分:0)

如果您愿意使用第三方控件......请使用非常适合使用的

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