如何在gridview中使用rowupdating和rowediting?请给我代码. [英] how to use rowupdating and rowediting in gridview? plz give me code.

查看:160
本文介绍了如何在gridview中使用rowupdating和rowediting?请给我代码.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个gridview,需要在其中编辑和删除数据.我需要怎么做才能做到这一点?我需要参加哪些活动?

我对此ans.plz并不满意,请给我详细的代码,该代码是在gridview的RowUpdating事件中编写的,以便打开文本框,然后我们可以更新或取消gridview的信息.

I have a gridview in my application, in which I need to edit and delete data. What do I need to do to achieve this? What events do I need to hook into?

i am not suficient of this ans.plz give me detail code which is written in RowUpdating event in gridview so that textboxs are open and after that we can update or cancel the information in gridview.

推荐答案

您应该使用链接按钮来实现此功能...


在aspx页面上



例如:-用于编辑

you should use linkbuttons for this functionality...


at aspx page



e.g:- for editing

<asp:linkbutton id="lbtn1" commandname="edit" 
commandargument=''<%#Eval("here the unique id")'' runat="server"/>



删除




for deleting


<asp:linkbutton id="lbtn2" commandname="delete"
commandargument=''<%#Eval("here the unique id")'' runat=server/>


用于更新


for updating

<asp:linkbutton id="lbtn3" commandname="update"
commandargument=''<%#Eval("here the unique id")'' runat="server"/>



用于gridview内部的这些链接按钮


在编码中触发行命令事件...


并在行命令事件



for these linkbuttons used inside the gridview


fire row command event in the coding...


and in row command event

if(e.commandname=="edit")
{
  int id=int.Parse(e.commandargument);



在哪里(e.commandargument将传递您要为其执行功能的每个唯一ID)

(为此ID使用编辑功能)



where (e.commandargument would pass each unique id for which you want to do functionality)

(and for this id use the editing functionality)

}
else if(e.commandname=="delete")
{
  int id=int.Parse(e.commandargument);



(将此ID作为参数传递给数据库,并应用删除功能)



(pass this id to the database as a parameter and apply delete functionality)

}
else if(e.commandname=="update")
{
int id=int.Parse(e.commandargument)

(pass this id to the database as a parameter and apply the update functionality)

}





记住要进行编辑以触发行编辑事件.

并为删除触发行删除事件..

并用于更新触发行更新事件..

希望这对您有帮助.:)





remember for editing fire the row editing event.

and for deleting fire the row deleting event..

and for updating fire the row updating event..

hope this helps.. :)


首先,不要向自己发布答案",请编辑您的帖子.其次,如果您不能像给出的答案那样理解详细的答案,那么再次询问不会改变答案,也不会改变您对编程知识不足以了解如何完成此简单任务的事实.如果您有客户,请让他们知道您是欺诈.如果您想学习,请购买一些基础书籍并通过这些基础书籍进行学习.
First of all, don''t post an ''answer'' to yourself, edit your post. Secondly, if you can''t understand a detailed answer like the one you were given, asking again will not change the answer, or change the fact that you don''t know enough about programming to understand how to do this simple task. If you have a client, let them know you are a fraud. If you''re trying to learn, buy some basic books and work through them.


这篇关于如何在gridview中使用rowupdating和rowediting?请给我代码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆