Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a single button in my form(SAVE) used to save records in database from text box, while selecting(Link Select in gridview) a row from the grid view, records displaying in text boxes.
Now i want to change, save text in button into update when event fire is, "dgvDetails_SelectedIndexChanged" and now the same button can update the records.
After pressing (updating) button text again shows SAVE...

Can anybody help me to resolved this solution

thanks in advance....
Posted

in the dgvDetails_SelectedIndexChanged event set the button's text to "Update".
btn_mysaveupdatebutton.Text = "Update";


When the button is pressed you do:
C#
private void btn_mysaveupdatebutton_Clicked(...){
  //Handle code here
  btn_mysaveupdatebutton.Text = "Save";
}


You're talking about a form, but the tags of the questions mention Asp.Net. There's a huge difference, if the response does not solve the problem, please update your question.
 
Share this answer
 
hi,

try Following

C#
protected void btnSave_Click(object sender, EventArgs e)
   {
       Button btnName = sender as Button;
       switch (btnName.ID)
       {
           case "Save":
               //ur Save Code
               break;
           case "Update":
               //ur update Code
               btnSave.Text = "Save";
               break;
       }
   }
   protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {
       btnSave.Text = "Update";
   }


best Luck
happy Coding
 
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