ASP.NET Conditionally Change ButtonField text at runTime
- by Rodney Vinyard
ASP.NET Conditionally Change ButtonField text at runTime
<asp:ButtonField CommandName="Edit" HeaderText="" Text="Edit" ButtonType="Link" />
protected void gvRequests_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//----------------------------------------------------
// If status = "Saved", change buttonField.LinkButton.Text to "Copy"
//----------------------------------------------------
if (e.Row.Cells[(int)gCol.Status].Text == "Saved")
{
//----------------------------------------------------
// no !
//----------------------------------------------------
//string x = e.Row.Cells[(int)gCol.EditLink].Text;
//e.Row.Cells[(int)gCol.EditLink].Text = "Copy";
//----------------------------------------------------
// yes !
//----------------------------------------------------
LinkButton linkButton = (LinkButton)e.Row.Cells[(int)gCol.EditLink].Controls[0];
linkButton.Text = "Copy";
}
}
}