Click here to Skip to main content
15,867,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a link button in gridview .Whenever i click on that link button that values are passed to particular fields.
Now i want to change that link button name as "Edit" to "Update".

Thanks&Regards
Hari
Posted
Comments
Maciej Los 18-Apr-13 6:17am    
Where are you stuck?
What have you done till now?
Hari Krishna Prasad Inakoti 18-Apr-13 6:21am    
hi Maciej,
i got struck at edit button click event .After edit i need to update that values with same button
Dnyaneshwar Kondbale 18-Apr-13 7:12am    
K Means you want to change the caption of button at run time,
Then if you click on Edit button Set button text property to Update and in page load you can set it Edit.
try smiler ways.

1 solution

If you get to the event handler you can use the sender object.

C#
Button btn = (Button)sender;
if(btn.Text == "Edit"){
  // do something
  btn.Text = "Update";
}
else{ 
  if(btn.Text == "Update"){
    //do something
    btn.Text = "Edit";
  }
}


This is meant to be pseudocode. Work it out to a more stable and workable version.

hope this helps.
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 18-Apr-13 7:53am    
@V.
i'm getting error like this.
Unable to cast object of type 'System.Web.UI.WebControls.GridView' to type 'System.Web.UI.WebControls.LinkButton'.
V. 18-Apr-13 7:57am    
What event triggers the event handler? If you added the event handler on cell-click or row-click or something, then that's logical. You need to
- or tie the Button object to an event handler
- or find the appropriate cell and get the Button object out. Check the quickwatch option in debug to play around with the objects.

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