Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done
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";
            }
        }
    }
Posted on Tuesday, March 1, 2011 8:28 AM GridView, Datagrid, DataList & Repeater | Back to top


Comments on this post: ASP.NET Conditionally Change ButtonField text at runTime

# re: ASP.NET Conditionally Change ButtonField text at runTime
Requesting Gravatar...
Hello,

I didn't understand what is "gCol" in your example.

Thank you in advance for your answer.

Regards.

Laurent.
Left by laurent on Apr 10, 2011 3:15 PM

# re: ASP.NET Conditionally Change ButtonField text at runTime
Requesting Gravatar...
Nice to know about this and this will help me in figure out my work.
Left by Post free classified Ads in Paki on Jul 23, 2012 11:50 AM

# re: ASP.NET Conditionally Change ButtonField text at runTime
Requesting Gravatar...
great,thanks,wish all the best.so useful
Left by Jordan Shoes on Mar 02, 2013 12:20 AM

# re: ASP.NET Conditionally Change ButtonField text at runTime
Requesting Gravatar...
So beautiful posts,all I like,hope to be better then,and enjoy yourself,good luck in your life.
Left by Prime institute of technology on Apr 14, 2013 5:27 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net