当单击更新按钮时,按钮的文本将被更改...我该怎么办 [英] when click on update button then the text of the button wii be changed...what i do

查看:55
本文介绍了当单击更新按钮时,按钮的文本将被更改...我该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在gridview中单击更新按钮,那么我希望单击按钮的文本将被更改,但其他按钮具有相同的条件... plzz告诉我如何使用循环...发送代码.我的代码是

if i click on the update button in gridview then i want that the text of the click button will be change but other button have same contaxt... plzz tell me how can i use for loop ...send me code.. my code is

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int index = GridView1.EditIndex;
GridViewRow row = GridView1.Rows[index];
TextBox t1 = row.FindControl("txtemp_name") as TextBox;
TextBox t2 = row.FindControl("txtemp_add") as TextBox;
TextBox t3 = row.FindControl("txtemp_mob") as TextBox;
TextBox t4 = row.FindControl("txtsalary") as TextBox;
string t5= GridView1.DataKeys[e.RowIndex].Value.ToString();
string dt = "update employee set emp_name='" + t1.Text + "',emp_add='" + t2.Text + "',emp_mob='" + t3.Text+ "',salary='" + t4.Text+ "'where emp_id=" + t5+ "";
con.Open();
cmd = new SqlCommand(dt, con);
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
con.Close();
bind();

}

推荐答案

嗨.

试试这个
Hi.

try this
If(Gridview1.RowUpdated==True)
{
button.text="Changed!";
}


protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int index = GridView1.EditIndex;
GridViewRow row = GridView1.Rows[index];
TextBox t1 = row.FindControl("txtemp_name") as TextBox;
TextBox t2 = row.FindControl("txtemp_add") as TextBox;
TextBox t3 = row.FindControl("txtemp_mob") as TextBox;
TextBox t4 = row.FindControl("txtsalary") as TextBox;
string t5= GridView1.DataKeys[e.RowIndex].Value.ToString();
string dt = "update employee set emp_name='" + t1.Text + "',emp_add='" + t2.Text + "',emp_mob='" + t3.Text+ "',salary='" + t4.Text+ "'where emp_id=" + t5+ "";
con.Open();
cmd = new SqlCommand(dt, con);
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
con.Close();
bind();
Button b1=row.FindControl("yourbuttonname") as Button;
b1.Text="Off"; 
}


这篇关于当单击更新按钮时,按钮的文本将被更改...我该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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