Using asp:UpdatePanel and asp:Repeater in Kentico 8.1

Chien VH asked on November 25, 2014 17:04

I have a repeater to bind the data from db and also created the pagination for that repeater. It works fine with the post back data. But, I don't want my web page be refreshed when going to other pages. I tried to use asp:updatepanel and asp:repeater to implement the requirement, but I got the error (Unable to load webpart). Here is the example: <asp:Repeater ID="rptRepeater" runat="server" OnItemDataBound="rptRepeater_ItemDataBound"> </asp:Repeater>

Anyone can help me?

Correct Answer

Chien VH answered on November 26, 2014 10:44

Because asp:UpdatePanel doesn't work inside a table. So, using div instead of using table and change the code behind when clicking to Prev and Next button It's worked. Anw, thanks all for your help.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Chien VH answered on November 25, 2014 17:07

Added missing sample code:

<asp:Repeater ID="rptRepeater" runat="server" OnItemDataBound="rptRepeater_ItemDataBound"> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <fieldset>
                Show Data Here
            </fieldset>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Repeater>
0 votesVote for this answer Mark as a Correct answer

Yehuda Lando answered on November 25, 2014 17:19 (last edited on November 25, 2014 17:19)

Put the update panel around the repeater and pager. If you use the portal mode, you can just check "Add update panel" in the web part or web part zone properties.

2 votesVote for this answer Mark as a Correct answer

Reza Zareian Fard answered on November 26, 2014 04:16

You can use below code instead: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> </asp:UpdatePanel>

Also you can use Kentico in built repeaters ( cms:BasicRepeater, cms:QueryRepeater, cms:Repeater) which gives you more options to work with Kentico items

0 votesVote for this answer Mark as a Correct answer

Reza Zareian Fard answered on November 26, 2014 04:18

You can use below code instead: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> </asp:UpdatePanel>

Also you can use Kentico in built repeaters ( cms:BasicRepeater, cms:QueryRepeater, cms:Repeater) which gives you more options to work with Kentico items

0 votesVote for this answer Mark as a Correct answer

Reza Zareian Fard answered on November 26, 2014 04:21

You can use below code instead:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Repeater ID="rptRepeater" runat="server" OnItemDataBound="rptRepeater_ItemDataBound"> 
            <ItemTemplate>
                <fieldset>
                    Show Data Here
                </fieldset>
            </ItemTemplate>
        </asp:Repeater>
    </ContentTemplate>
</asp:UpdatePanel>

Also you can use Kentico in built repeaters ( cms:BasicRepeater, cms:QueryRepeater, cms:Repeater) which gives you more options to work with Kentico items

1 votesVote for this answer Mark as a Correct answer

Chien VH answered on November 26, 2014 04:35

Thanks all!

@REZA ZAREIAN FARD Yesterday, I was use your way, but It's not worked. However, today I just re-tried and the application can run without error. But, the page still refresh. Here is updated code:

.ascx file:

<asp:UpdatePanel ID="upReportsList" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Repeater ID="rptReportsList" runat="server">
            <ItemTemplate>

                <tr>
                    <td class="auto-style2">&nbsp;</td>
                    <td class="auto-style3">
                        <a href='/Create-Report/Detail-Report.aspx?ReportId=<%# Eval("ItemID") %>'>
                            <%# Eval("ItemID") %>
                        </a>
                    </td>
                    <td>
                        <a href='/Create-Report/Detail-Report.aspx?ReportId=<%# Eval("ItemID") %>'>
                            <%# Eval("ItemReportName") %>
                        </a>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>
        <asp:Label ID="lblPageCount" runat="server" Style="font-weight: 700"></asp:Label>
        <asp:Button ID="btnPrev" runat="server" Text="Previous" OnClick="btnPrev_Click" />
        <asp:Button ID="btnNext" runat="server" Text="Next" OnClick="btnNext_Click" />
    </ContentTemplate>
</asp:UpdatePanel>

Code behind for buttons action:

protected void btnNext_Click(object sender, EventArgs e)
{
    //send to next page
    Response.Redirect(string.Format("{0}{1}", "~/Reports-List.aspx?Page=", Convert.ToString(_pageNum + 1)));
}
protected void btnPrev_Click(object sender, EventArgs e)
{
    //send to previous page
    Response.Redirect(string.Format("{0}{1}", "~/Reports-List.aspx?Page=", Convert.ToString(_pageNum - 1)));
}

Please let me know where do I need to change?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 26, 2014 06:43

Your page is refreshing because you are specifically stating Response.Redirect() You are telling the page to navigate away from the current page and go to another page, it doesn't matter if you're adding new parameters or not, your redirecting the page an update panel will do nothing for that.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.