如何编辑n更新GRID VIEW中的行 [英] How to edit n update a row in GRID VIEW
本文介绍了如何编辑n更新GRID VIEW中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
在我的应用程序中,我以网格视图的形式显示数据。如何编辑行并在网格视图中更新?
Hi
In my application i have displayed data in the form of grid view. How can i edit a row and update it in the grid view??
推荐答案
您u可以使用Rowedititng属性..
Youucan use Rowedititng property..
<Columns>
<asp:TemplateField HeaderText="Filed">
<ItemTemplate>
<asp:Label runat="server" ID="category" Text='<%#Eval("field1") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txt1" Text='<%#Eval("filed1") %>' ValidationGroup="v1" />
<asp:RequiredFieldValidator runat="server" ID="req1" ControlToValidate="txt1" ErrorMessage="*" ValidationGroup="v1" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" />
<asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" ValidationGroup="v1" />
<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />
</EditItemTemplate>
<ControlStyle ForeColor="#6600FF" />
<ItemStyle Font-Size="Medium" />
</asp:TemplateField>
</Columns>
$ b
比在row_editing属性中.....
than in row_editing property.....
GridView1.EditIndex = e.NewEditIndex;
BindGridData();
BindGridData中的
你 u 可以用你选择的字段绑定你的网格。
现在,row_Updating属性
in BindGridData youu can bind your grid with selected field.
now,row_Updating Property
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox txt1 = (TextBox)row.FindControl("txt1");
GridView1.EditIndex = -1;
string s="update query";
Sqlcommand cmd=new Sqlcommand(s,connection object);
cmd.executenonquery();
BindGridData();
}
希望你得到它并解决你的问题。
谢谢..
Hope You Got it and Solve Your Problem.
Thanks..
请参考以下主题:
ASP.NET 2.0中的可编辑GridView [ ^ ]
功能齐全的可编辑GridView控件 [ ^ ]
在ASP.NET中编辑单个GridView单元格 [ ^ ]
Userful GridView ASP.NET [ ^ ]
ASP.NET的GridView示例 [ ^ ]
Please refer following threads:
Editable GridView in ASP.NET 2.0[^]
Full-featured Editable GridView Control[^]
Edit Individual GridView Cells in ASP.NET[^]
Userful GridView ASP.NET[^]
GridView Examples for ASP.NET[^]
hi
我希望这个链接对你来说是完整的。
[编辑和更新网格示例]
这篇关于如何编辑n更新GRID VIEW中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文