Changing the text of a GridView buttonfield text dynamically
ASP.NET
1
Posts
1
Posters
0
Views
1
Watching
-
I have a GridView with a buttonfield column that I am using to edit and save the value of records. The problem I am having is that in the Grid's Row Command event I want to change the button's text from "Edit" to "Save" but my code below doesn't work. Can anyone see what I'm doing wrong? HTML:
Code behind:
protected void gvProducts\_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Edit": int index = Convert.ToInt32(e.CommandArgument); Button myButton = null; myButton = (Button)gvProducts.Rows\[index\].Cells\[0\].Controls\[0\]; myButton.Text = "Save"; return; case "Delete": return; default: return; } }