Access User Control DataGrid Controls from parent page

2.5k Views Asked by At

here my code-

GridView gvCondition = (GridView)this.FindControl("ucCondition").FindControl("gvCondition");
gvCondition.DataSource = objConditionFieldCollection;
gvCondition.DataBind();

but it is throwing as exception Object reference not set to an instance of an object.How can I access user control's gridview control from parent page?

1

There are 1 best solutions below

4
On

I don't know where you trying to access the UserControl's GridView, but why don't you simply expose a public property in the UserControl that returns the GridView(f.e. ConditionView)?