This is a migrated thread and some comments may be shown as answers.

Repeter inside RadDock doesn't fire Item Command

2 Answers 57 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Faten
Top achievements
Rank 1
Faten asked on 24 May 2012, 05:05 PM
I'm using repeater inside a user control, which is dynamically generated by other parent page inside raddock, so the hierarchy is: Page, RadDock, User Control, Repeater.

My problem is that the repeater doesn't fire Item command event,
Here is the code of the repeater inside the user control:

<asp:Repeater ID="rptrFirst5Assignments" runat="server"
    onitemdatabound="rptrFirst5Assignments_ItemDataBound"
    onitemcommand="rptrFirst5Assignments_ItemCommand"
    onitemcreated="rptrFirst5Assignments_ItemCreated" >
    <ItemTemplate>
        <table >
            <tr >
                <td >
                    <asp:Label ID="lblAssignmentID" runat="server" Text='<%# Bind("Asm_ID") %>'
                        Visible="false"></asp:Label>
                    <asp:Label ID="lblCreatedByID" runat="server" Text='<%# Bind("Asm_CreatedBy") %>'
                    Visible="false"></asp:Label>
                    <asp:Label ID="lblAssignment" runat="server" CssClass="alltext" Text='<%# Bind("Asm_Body") %>'></asp:Label>
                </td>
                 <td style="float:left;">
                  
                 <asp:LinkButton ID="btnDelete" runat="server" CausesValidation="false" CssClass="link-delete" CommandName="Delete"
                                CommandArgument='<%# Eval("Asm_ID")%>' /></td>
            </tr>
        </table>
         
    </ItemTemplate>
     
</asp:Repeater>


And this is how i dynamically create the rad docks in the parent page:
as mentioned in the demo of rad dock:
if (!Page.IsPostBack)
            {
CreateDocksFirstTime();
 
 
for (int i = 0; i < RadDockLayout1.Controls.Count; i++)
                {
                    if (RadDockLayout1.Controls[i].GetType() == typeof(RadDock))
                    {
                        RadDock radDock = (RadDock)RadDockLayout1.Controls[i];
                            List<Assignment> assignments = AssignmentBL.SearchTodayAssignments(3,5,0, SelectedDate);
                           ((Controls.TeacherDateView.TeacherDateViewAssignments)radDock.ContentContainer.Controls[0]).FillData(assignments);
                            radDock.Title =  assignments.Count ;         
                    }
                }
}
  
private void CreateDocksFirstTime()
        {
            RadDock dock3 = CreateRadDock();
  
            //adding the dock to the docklayout and then docking it to the zone to avoid ViewState issues on subsequent postback
            RadDockLayout1.Controls.Add(dock3);
            dock3.Dock(RadDockZoneAssignments);
            dock3.Height = new Unit(300, UnitType.Pixel);
  
            CreateSaveStateTrigger(dock3);
  
            //Load the selected widget in the RadDock control
            dock3.Tag = "Controls\\TeacherDateView\\TeacherDateViewAssignments.ascx";
            LoadWidget(dock3);
        }
  
  
  
  
private void LoadWidget(RadDock dock)
        {
            if (string.IsNullOrEmpty(dock.Tag))
            {
                return;
            }
            Control widget = LoadControl(dock.Tag);
            widget.EnableViewState = false;
            dock.ContentContainer.Controls.Add(widget);
        }



And then i re create them from the saved state at Page_Init as mentioned in the RadDock Demo
protected void Page_Init(object sender, EventArgs e)
        {
            //Recreate the docks in order to ensure their proper operation
            for (int i = 0; i < CurrentDockStates.Count; i++)
            {
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
                RadDockLayout1.Controls.Add(dock);
                //We want to save the dock state every time a dock is moved.
                CreateSaveStateTrigger(dock);
                //Load the selected widget
                LoadWidget(dock);
                if (CurrentDockStates[i].Closed == true)
                {
                    dock.Visible = false;
                }
}
}


Note that i have buttons inside the user control and they work correctly, Also repeater_ItemDataBound and ItemCreated event handlers are firing correctly.


Any suggestions??

2 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 29 May 2012, 10:47 AM
Hi Faten,

Please check if the dynamically added RadDock controls are recreated correctly, if the value of their properties ID and UniqueName is always the same.

You can check the proper setup in the online demo My Portal. To replicate your scenario I have created a user control, which is attached to this post, and I have included it in the user control selector in the demo:
<asp:DropDownList runat="server" ID="DroptDownWidget" Width="150">
    <asp:ListItem Text="RepeaterControl.ascx" Value="~/Dock/Common/RepeaterControl.ascx"></asp:ListItem>
    <asp:ListItem Text="ExchangeRatesCS.ascx" Value="~/Dock/Common/ExchangeRatesCS.ascx"
        Selected="true"></asp:ListItem>
    <asp:ListItem Text="TelerikNews.ascx" Value="~/Dock/Common/TelerikNews.ascx"></asp:ListItem>
    <asp:ListItem Text="TelerikBlogs.ascx" Value="~/Dock/Common/TelerikBlogs.ascx"></asp:ListItem>
    <asp:ListItem Text="HoroscopesCS.ascx" Value="~/Dock/Common/HoroscopesCS.ascx"></asp:ListItem>
    <asp:ListItem Text="WeatherCS.ascx" Value="~/Dock/Common/WeatherCS.ascx"></asp:ListItem>
</asp:DropDownList>

If you are still having difficulties after modifying the demo as described above, please provide a reliable steps for reproducing the problem, as the ItemCommand event is firing on my end.

All the best,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Faten
Top achievements
Rank 1
answered on 29 May 2012, 12:32 PM
Thanks a lot for your reply,  the rad docks are re created correctly with the same ID and unique name,but The problem is solved by rebinding the repeater data at every postback. (after recreation)


Thanks a lot
Tags
Dock
Asked by
Faten
Top achievements
Rank 1
Answers by
Slav
Telerik team
Faten
Top achievements
Rank 1
Share this question
or