简体   繁体   中英

LinkButton on GridView - after selected

I asked the next question:

Get current GridView column value

And i got the right answer. now i want - that after click on the linkbutton that i have there - the text of the button will change to: "done" or its visble will be false.

how can id to that?

if referencing to the same answer, you can do something like

protected void Gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
    int selectedRowIndex = Convert.ToInt32(e.CommandArgument);
    var row = Gv.Rows[selectedRowIndex ];
    var btn = row.FindControl("LinkButton1") as LinkButton;
    if(btn != null)
    {
       btn.visible = false;
    }

}

In RowCommand event handler,

LinkButton button=e.CommandSource as LinkButton;
button.Text="Done";

on click event of linkbutten...

protected void lnkDownload_Click(object sender, EventArgs e)
{
    LinkButton lnkbtn = (LinkButton)sender;
    lnkbtn.Text = "Done";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM