More in this section

Forums / Developing with Sitefinity / Intra-site Modules using UserControls and LinqDataSources not Working

Intra-site Modules using UserControls and LinqDataSources not Working

2 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    27 Oct 2009
    Link to this post
    Hi There,

    I'm working on integrating a series of user controls that work just fine when loaded into a stand alone aspx page, but when I try to load them into a ControlPanel.asxc in Sitefinity Admin it seems like none of the events are wired up.

    Here's some code snipits:
    RadGrid with the following:
    <telerik:RadGrid ID="RadGrid1" runat="server"  
        AutoGenerateColumns="False" 
        AllowAutomaticDeletes="True"  
        AllowAutomaticInserts="True"  
        AllowAutomaticUpdates="True"  
        AllowFilteringByColumn="True"  
        AllowPaging="True"  
        AllowSorting="True"  
        AutoGenerateDeleteColumn="True"  
        AutoGenerateEditColumn="True" 
        GridLines="None" 
        CssClass="listItems" 
        DataSourceID="LinqDataSource1"  
        > 
    and then the following LinqDataSource:
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"  
        ContextTypeName="MyAppDataContext" EnableDelete="True"  
        EnableInsert="True" EnableUpdate="True" TableName="Departments"
    </asp:LinqDataSource> 

    This will render the grid fine, but clicking on the Edit/Delete commands in the grid dosen't do anything, it's like the events aren't wired up. They can be wired up manually of course but since I have over 20 existing user controls that all work as is, I'm looking for a more elegant way to integrate them without having to manually wire up each one. Is this possible?

    Also, something that may be relevant, the user controls are loaded into ControlPanel.ascx by creating a Control and adding it to a place holder on the page when a link in the CommandPanel.ascx is clicked.

    Any help is greatly appreciated.
    Cheers,
    Phill
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Oct 2009
    Link to this post
    Hi Phill Hodgkinson,

    Thank you for using our services.

    Can you try ti set AutoEventsWireup to true for your user controls in the markup of the files:
    <%@ Control Language="C#" AutoEventWireup="true" ...%>

    This is by default set to false, therefore you will have to manually create event handlers for the grid events in your code file:
    protected void Page_Load(object sender, EventArgs e)
       {
           RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
           RadGrid1.InsertCommand += new GridCommandEventHandler(RadGrid1_InsertCommand);
           RadGrid1.UpdateCommand += new GridCommandEventHandler(RadGrid1_UpdateCommand);
           RadGrid1.DeleteCommand += new GridCommandEventHandler(RadGrid1_DeleteCommand);
       }
       void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
       {
     
       }
       void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
       {
     
       }
       void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
       {
       }

    Either of those should wire your events handlers in your user controls. We do not have any known problems with wiring event handlers in user controls and their use in the Sitefinity admin section.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered