abhijitcb:
I have two user controls namely CanvasGrid.ascx and GridUtility.ascx. CanvasGrid.ascx is just a container for displaying GridView control in a placedholder GridPH. I want to get the checked rows from GridView control of CanvasGrid.ascx and do tagging against specific name selected from the TagDropDownList of GridUtility.ascx. But the problem is that I am not geting the reference of GridView as it is coming null everytime even when I am using FindControl() to find the GridView control on the page. GridUtility.ascx is a part of CanvasGrid.ascx and it is placed in a placeholder GridUtilityPH using LoadControl() at pageLoad of CanvasGrid.ascx
Hi Abhijit,
Have you try the following code with loadcontrol method in your web form page.
protected void Page_Load(object sender, EventArgs e)
{
Control ctl = Page.LoadControl("~/CanvasGrid.ascx ");
Control gridview_control = ctl.FindControl("Gridview_id");
Session["GridView"] = gridview_control;
}
The code snippet above put the gridview_control into a session object; therefore, you can access
the gridview control by the session object in another user control.
Hope this Information is helpful!
Xun
Regards,
Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.