我应该编写什么代码来更新Asp.Net中的Gridview控件中的数据? [英] What Is The Code Should I Write To Update Data In A Gridview Control In Asp.Net?
本文介绍了我应该编写什么代码来更新Asp.Net中的Gridview控件中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的程序中
i编写了用于插入,更新,删除操作和将数据显示到gridview控件的代码,但这里我的问题是当我同时更新/删除/插入记录gridview时应该更新它的细节。我应该编写什么代码?
提前谢谢
解决方案
你必须添加Gridview详细信息方法..
例如。
DataTable dt = new DataTable();
dt = ObjBAL。 methodname();
GV.DataSource = dt;
GV.Databind();
此类型Gridmethod,你应该在插入,更新,删除编码后调用..
http://www.c-sharpcorner.com/uploadfile/raj1979/select-add-update-and-delete-data -in-a-Asp-Net-gridview-control / [ ^ ]
这是完整的解决方案。
问候,
Praveen Nelge
http://msdn.microsoft.com/en-library/system.web.ui.webcontrols.gridview.rowcancelingedit%28v=vs.110%29.aspx
这是一些通用代码:
< asp:GridView ID = GridView1
runat = < span class =code-string> server
DataSourceID = SqlDataSource1
AutoGenerateColumns = true
allowpaging = true
PageSize = 50
AllowSorting = true
DataKeyNames = id
AutoGenerateEditButton = true
AutoGenerateDeleteButton = true
/>
< asp:SqlDataSource
id = SqlDataSource1
ConnectionString = <%
in my program
i wrote the code for inserting,updating,deleting operations and displaying data into a gridview control but here my problem is when i update/delete/insert records at the same time the gridview should be update the details on it. what is the code i should write?
Thanks in advance解决方案You must add the Gridview details Method..
For example.
DataTable dt = new DataTable();
dt = ObjBAL.methodname();
GV.DataSource = dt;
GV.Databind();
This type of Gridmethod ,You should call after insertion,updation ,deletion coding..
http://www.c-sharpcorner.com/uploadfile/raj1979/select-add-update-and-delete-data-in-a-Asp-Net-gridview-control/[^]
Here is the complete solution.
Regards,
Praveen Nelge
http://msdn.microsoft.com/en-library/system.web.ui.webcontrols.gridview.rowcancelingedit%28v=vs.110%29.aspx
Here is some general code:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="true" allowpaging="true" PageSize="50" AllowSorting="true" DataKeyNames="id" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" /> <asp:SqlDataSource id="SqlDataSource1" ConnectionString="<%
这篇关于我应该编写什么代码来更新Asp.Net中的Gridview控件中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文