Kenyana
Kenyana

Reputation: 71

FindControl does not work in GridView

void GridView1_RowCreated(Object sender, GridViewRowEventArgs e) {

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        (e.Row.FindControl("linkDocs") as HyperLink).Visible = false;


    }

}

I can't get that code sample to work. I need to access a hyperlink control on my page.

I have a master page setup.

Upvotes: 0

Views: 377

Answers (1)

citronas
citronas

Reputation: 19365

Make sure you are using a TemplateField containing a Hyperlink with ID="linkDocs".

Maybe the OnRowDataBound Event is better suited for your needs.

Upvotes: 1

Related Questions