Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Call UserControl in code behind c#

There is a UserControl named as "UcGridMastersUI.ascx" in my WebApplication, below is the code:

<div class="row">
<div class="col-md-12">

<cc1:XamGridEx ID="grdXamGrid" runat="server">


I have dragged and dropped this UserControl in "Test.aspx" page, below is the code:

<asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager>

<uc1:UcGridMastersUI ID="UcGridMastersUI1" runat="server" />

I need to know how shall I call and bind the Grid "grdXamGrid" (using Linq) which is inside UserControl into "Test.aspx.cs" page using C# code.

I am using Asp.Net with WebDataGrid infragistics control and oracle database.
I am very new in infragistics. Kindly let me know how to do this.

Any help would be appreciated. Thanks in advance.

  • 22832
    Offline posted

    To bind the WebDataGrid to data, you would set it's DataSource property and to do this you either need access to the control from outside the user control or you need access to the data source you which to set from inside the user control.  This would be the same for accessing the property of any control that is on the UserControl from the containing page and isn't specific to the Infragistics controls.

    Here are a few possible ways to do this:

    • Expose a property for the DataSource on the UserControl so that you can set that and within the UserControl you can use it.  See User Control - Custom Properties on StackOverflow for an example of this approach.
    • Exposing the grid as a property on the UserControl so that you have access to it from the parent page. 
    • Find the control with FindControl from the parent page.

    Let me know if you have any questions.