Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Call UserControl in code behind c#

Call UserControl in code behind c#

New Discussion
Pree Khanna
Pree Khanna asked on May 19, 2017 7:33 PM

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">
</cc1:XamGridEx>

</div>
</div>

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

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

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

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.

Sign In to post a reply

Replies

  • 0
    Alan Halama
    Alan Halama answered on May 19, 2017 7:33 PM

    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.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Pree Khanna
Favorites
0
Replies
1
Created On
May 19, 2017
Last Post
8 years, 9 months ago

Suggested Discussions

Created by

Created on

May 19, 2017 7:33 PM

Last activity on

Feb 23, 2026 8:08 PM