0

I have grid view with link button named 'CLICK'. when clicks on this link button I wants to change its text to "CLICKED" I have done like this, on row command

if (e.CommandName == "ARCHIVE") //FOR SETTING THE VIEW LINK BUTTON
     {

             LinkButton lnkbtn = (LinkButton)sender;
            lnkbtn.Text = "viewed";
            lnkbtn.Enabled = false;


     }

but its not working. please help

ARATHY
  • 349
  • 5
  • 13
  • 29

5 Answers5

1

Try like this...

if (e.CommandName == "ARCHIVE") //FOR SETTING THE VIEW LINK BUTTON
     {

             LinkButton lnkbtn = (LinkButton)e.CommandSource;
            lnkbtn.Text = "viewed";
            lnkbtn.Enabled = false;


     }
Amit Singh
  • 8,039
  • 20
  • 29
1

Try this using javascript:

 OnClientClick="javascript:if (this.value=='Archieve') this.value = 'Viewed';else this.value = 'Bookmark';"></asp:LinkButton>
Manu
  • 418
  • 3
  • 8
  • 20
1

Another way is:

if (e.CommandName == "ARCHIEVE")
    {
        LinkButton lnkButton = (LinkButton)e.CommandSource;
        if (lnkButton != null)

            if (lnkButton.Text.ToUpper() == "ARCHIEVE")
            {

                lnkButton.Text = "VIEWED";
            }

            else if (lnkButton.Text.ToUpper() == "VIEWED")
            {

                lnkButton.Text = "ARCHIEVE";
            }
    }
Manu
  • 418
  • 3
  • 8
  • 20
0
if (e.CommandName == "ARCHIVE") //FOR SETTING THE VIEW LINK BUTTON
{
    GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;

    LinkButton lnkbtn = (LinkButton)row.FindControl("lnkClick"); // LinkButton ID
    lnkbtn.Text = "viewed";
    lnkbtn.Enabled = false;
}

Reference - How to get GridView's LinkButton ForeColor in RowCommand Event?

Community
  • 1
  • 1
Tadit Dash
  • 305
  • 23
  • 60
  • 141
0
 if (e.CommandName == "ARCHIVE")
            {
                LinkButton lnkbtn= (LinkButton)e.CommandSource;
                lnkbtn.Text = "Clicked";
                lnkbtn.Enabled = false;
            }
Suraj Singh
  • 4,041
  • 1
  • 21
  • 36