Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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();

}
Posted
Updated 30-Aug-12 9:54am
v2

Hi.

try this
C#
If(Gridview1.RowUpdated==True)
{
button.text="Changed!";
}
 
Share this answer
 
Comments
Karl Heinz Hamburg 30-Aug-12 4:24am    
i want to add a for loop. if i update the text and click on the update button such as on..after click the button the gridview is updated and the text will changed of the button is off.
Karl Heinz Hamburg 30-Aug-12 4:24am    
and other button text not changed
C#
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"; 
}
 
Share this answer
 
Comments
Karl Heinz Hamburg 30-Aug-12 4:37am    
its not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900