Click here to Skip to main content
15,895,799 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
lang="cs">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 29-Aug-12 21:56pm
v4
Comments
Abhi KA 30-Aug-12 3:16am    
insert code
Abhi KA 30-Aug-12 3:17am    
u need to change text of button
Karl Heinz Hamburg 30-Aug-12 3:57am    
i insert code

1 solution

Go to the RowCommand event of your GridView. Find the Button and change the text.
Write the following in your RowCommand:
C#
Button btnMyBtn = (Button)e.Item.FindControl("btnMyBtn");
btnMyBtn.Text = "New Text";



--Amit
 
Share this answer
 

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