user594849
user594849

Reputation: 141

How to change the text of linkbutton inside datalist item template field on linkbutton click event?

I have a linkbutton inside datalist1 item template field, i want when user click on linkbutton then its text would be "enable" and if the linkbutton text is "enable" and panel1 will be visible then again on linkbutton click event linkbutton text would be "disable"and panel1 will be hidden...

Upvotes: 0

Views: 1738

Answers (1)

Ken Wayne VanderLinde
Ken Wayne VanderLinde

Reputation: 19349

Here is the applicable code:

protected void Link_Click(object sender, EventArgs e)
{
    LinkButton link = sender as LinkButton;
    if(link.Text == "enabled")
    {
        link.Text = "disabled";
        panel1.Visible = false;
    }
    else
    {
        link.Text = "enabled";
        panel1.Visible = true;
    }
}

Upvotes: 1

Related Questions