ASP.NET Conditionally Change ButtonField text at runTime
Posted
by Rodney Vinyard
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Rodney Vinyard
Published on Tue, 01 Mar 2011 14:28:18 GMT
Indexed on
2011/03/01
15:25 UTC
Read the original article
Hit count: 320
Filed under:
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";
}
}
}
© Geeks with Blogs or respective owner