Huzaifa
Huzaifa

Reputation: 1171

Not able to access gridview inside tab panel from code behind asp.net

I have a gridview to which I am allocating a data source and binding it on Button Click in Code behind.

Code:

protected void Button2_Click(object sender, EventArgs e)
    {
        GridView1.DataSource=List;
        GridView1.DataBind();
    }

asp.net

It was working fine until I decided to put this grid view inside a tab panel. As soon as I put the gridview inside the tab it is not able to access the gridview.

I tried using FindControl to find GridView3 but its not working.

Can somebody suggest me a work around?

Thanks

Upvotes: 1

Views: 1139

Answers (2)

Bibek Gautam
Bibek Gautam

Reputation: 592

try looping over all the containers in tab-panel:

foreach(var c in tab_panel.Controls)
{
   if(c is your control)
     return c;

   if(c is a container)
     loop through all controls in c;//recursion
}

Upvotes: 1

Wjdavis5
Wjdavis5

Reputation: 4151

Have you tried:TabPanel.Children?

Upvotes: 1

Related Questions