如何在ASP.Net中编辑gridview中的行 [英] How to edit rows in gridview in ASP.Net

查看:318
本文介绍了如何在ASP.Net中编辑gridview中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,

我有gridview,它包含文本框,我将数据绑定到该文本框现在我想要更改文本框数据并传输到DB,我会在GridViewRowCommand事件,但是有一些问题,所以即时尝试在GriViewRowUpdating事件中,但即使是在编辑按钮点击事件中也不会激活...请帮帮我????

//这个我的代码



public void GridView1_RowUpdating(object sender,GridViewUpdateEventArgs e)

{



string CheckpointName =((TextBox)GridView1.Rows [e.RowIndex]

.FindControl(somevalue))。Text;

string Query =UPDATE check_points SET CHECKPOINT_NAME ='+ CheckpointName +'WHERE ROOT_ID ='+ TextBox1.Text +';

if(access.insert_delete_update(Query))

{

ScriptManager.RegisterStartupScript(this,this.GetType(),

" Message"," alert(Error);",true);

}

GridView1.EditIndex = -1;

GridView1.DataBind();



}

Dear friends,
I have gridview and its contain textboxes and Im bind data to that textboxes now im want to make changes that text box data and transfer to DB,I'l do that inside the GridViewRowCommand event,but there are some issues,so im try that inside the GriViewRowUpdating event but that even is does not fire in edit button click event...Please help me????
//this my code

public void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

string CheckpointName = ((TextBox)GridView1.Rows[e.RowIndex]
.FindControl(somevalue)).Text;
string Query = "UPDATE check_points SET CHECKPOINT_NAME = '" + CheckpointName + "' WHERE ROOT_ID='" + TextBox1.Text + "'";
if (access.insert_delete_update(Query))
{
ScriptManager.RegisterStartupScript(this, this.GetType(),
"Message", "alert(Error);", true);
}
GridView1.EditIndex = -1;
GridView1.DataBind();

}

推荐答案

你好,



试试这个链接。



Asp.net在gridview中插入,编辑,更新,删除数据



谢谢

animesh
Hello ,

Try this link.

Asp.net insert, Edit, update, delete data in gridview

thanks
animesh


您首先在Gridview中处理RowEditing事件
You first Handle RowEditing event in Gridview


这篇关于如何在ASP.Net中编辑gridview中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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