0

我有名为“CLICK”的链接按钮的网格视图。当单击此链接按钮时,我想将其文本更改为“CLICKED”我已经这样做了,在行命令上

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

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


     }

但它不工作。请帮忙

4

5 回答 5

1

另一种方法是:

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";
            }
    }
于 2013-10-03T09:47:34.920 回答
1

试试这样...

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

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


     }
于 2013-10-03T09:36:41.417 回答
1

使用 javascript 试试这个:

 OnClientClick="javascript:if (this.value=='Archieve') this.value = 'Viewed';else this.value = 'Bookmark';"></asp:LinkButton>
于 2013-10-03T09:43:54.123 回答
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;
}

参考 -如何在 RowCommand 事件中获取 GridView 的 LinkBut​​ton ForeColor?

于 2013-10-03T09:50:28.830 回答
0
 if (e.CommandName == "ARCHIVE")
            {
                LinkButton lnkbtn= (LinkButton)e.CommandSource;
                lnkbtn.Text = "Clicked";
                lnkbtn.Enabled = false;
            }
于 2013-10-03T09:58:53.113 回答