Using FindControl to get GridView in a Content Page

前端 未结 3 1596
忘掉有多难
忘掉有多难 2020-12-21 14:32

I would like to find a GridView Control within a separate class and I am having issues doing so. I even tried placing my code in the aspx.cs page to no avail. I

3条回答
  •  醉梦人生
    2020-12-21 15:15

    Don't get the page from HttpContext if you are already within the page. Instead, is there a control you can use FindControl from? Instead of use page, use:

    parentControl.FindControl("GridView1") as GridView;
    

    Instead. There is an issue with finding the grid from the page level, and using a lower level control closer to the grid will have better success.

提交回复
热议问题