如何在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