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

DataSource OnClick codebehind

4 Answers 236 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Son
Top achievements
Rank 1
Son asked on 01 Sep 2016, 04:22 AM

I changed something from demo example to my project and i use datasource in codebehind.  DataPager still works fine if i put RadListView datasource in PageLoad but DataPager doesn't work when i put RadListView datasource in event click of Button. Can you help me, please?

 - aspx:

<telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClick="Button1_Click"></telerik:RadButton>
        <br />
        <div>
                    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="0">
            </telerik:RadAjaxLoadingPanel>
            <asp:Panel ID="ListViewPanel1" runat="server">
                <telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server"
                    allowsorting="true" ItemPlaceholderID="ProductsHolder">
                    <LayoutTemplate>
                            <asp:Panel ID="ProductsHolder" runat="server">
                            </asp:Panel>
                            <table>
                                <tr>
                                    <td>
                                        <telerik:RadDataPager RenderMode="Lightweight" ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                            PageSize="6">
                                            <Fields>
                                                <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
                                                <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
                                                <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
                                                <telerik:RadDataPagerPageSizeField PageSizeText="Page size: "></telerik:RadDataPagerPageSizeField>
                                                <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                                                    TextBoxWidth="30"></telerik:RadDataPagerGoToPageField>
                                                <telerik:RadDataPagerTemplatePageField>
                                                    <PagerTemplate>
                                                        <div style="float: right; line-height: 34px; margin-left: 10px;">
                                                            Items
                                                        <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>"></asp:Label>
                                                            to
                                                        <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize) ? Container.Owner.StartRowIndex+Container.Owner.PageSize : Container.Owner.TotalRowCount %>"></asp:Label>
                                                            of
                                                        <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>"></asp:Label>
                                                            <br />
                                                        </div>
                                                    </PagerTemplate>
                                                </telerik:RadDataPagerTemplatePageField>
                                            </Fields>
                                        </telerik:RadDataPager>
                                    </td>
                                </tr>
                            </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                         <table>
                                <tr>
                                    <td style="width: 140px; text-align: left; height: 120px">
                                        <asp:Image ID="Img1" runat="server"
                                            ImageUrl='<%# Eval("_Image") %>' Height="100" Width="130" />
                                    </td>
                                    <td style="vertical-align: top; text-align: left">
                                        <asp:LinkButton runat="server" ID="Title" Font-Bold="true" CommandName="Select"
                                            Text='<%# Eval("_Title") %>'></asp:LinkButton>
                                        <asp:Label runat="server" ID="lblink" Font-Size="Small"
                                            Text='<%# Eval("_Link") %>' Visible="false" />
                                    </td>
                                </tr>
                            </table>
                    </ItemTemplate>
                </telerik:RadListView>  
            </asp:Panel>
          
            <asp:SqlDataSource ID="SqlDS" runat="server" ConnectionString="<%$ appSettings:sqlconn %>"
                ProviderName="System.Data.SqlClient" ></asp:SqlDataSource>

 

- aspx.cs work fine (don't use Button):

        protected void Page_Load(object sender, EventArgs e)
        {
            _News.NewsList("20", "", "08/20/2016", "08/30/2016", "0", "0", 0);
            RadListView1.DataSource = _News._znews;
            RadListView1.DataBind();
        }

- aspx.cs DataPager doesn't work:

        protected void Page_Load(object sender, EventArgs e)

         {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            _News.NewsList("20", "", "08/20/2016", "08/30/2016", "0", "0", 0);
            RadListView1.DataSource = _News._znews;
            RadListView1.DataBind();
        }

Thanks. 

4 Answers, 1 is accepted

Sort by
0
Son
Top achievements
Rank 1
answered on 05 Sep 2016, 02:27 AM

Excute me, more, because after clicked, i need reload ListView every 15 mins (Timepicker) without refreshing pager to 1, Do you have any idea? 

Example in my picture, after 15', i can have options to keep it 'page 3' after refreshed or reload it to 'page1'

(both listview and pager)

0
Son
Top achievements
Rank 1
answered on 05 Sep 2016, 08:42 AM

Sorry, Maybe i'm wrong, the problem is not datapager, it's ajax manager :(

- I read demo of RadAjaxManager, RadAjaxLoadingPanel but i don't understand all. 
What displace UpdateMode, AutoPostBack, Update() in non-Rad controls? 

- Example about Timer with RadAjaxManager is ok  but can i choose an option to reset to (page 1)?

0
Accepted
Eyup
Telerik team
answered on 06 Sep 2016, 05:57 AM
Hi Son,

First of all, please note that using RadAjaxPanel simultaneously with RadAjaxManager or UpdatePanel ( or implementing multiple wrapped RadAjaxPanels ) is not a supported scenario and we highly recommend to avoid such implementation. Please replace the RadAjaxPanel with regular asp:Panel or remove the RadAjaxManager:
http://www.telerik.com/help/aspnet-ajax/ajax-controls-in-ajaxpanel-and-ajaxsettings.html


Also, when developing your applications, temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering, and make sure that the application works without AJAX.


Please note that performing complex list view operations such as Inserting, Deleting, Updating, Grouping, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations. Therefore, we suggest you to avoid Simple Databinding (DataBind() method) and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
  Declarative DataSource
  Advanced Data Binding
(NeedDataSource event)


As for ajaxifying Timer functionality, you can check the following live sample:
http://demos.telerik.com/aspnet-ajax/ajaxmanager/application-scenarios/ajaxify-timer/defaultcs.aspx

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Son
Top achievements
Rank 1
answered on 06 Sep 2016, 09:22 AM
NeedDataSource without DataBind() is what i need. Thank you so much, Eyup.
Tags
DataPager
Asked by
Son
Top achievements
Rank 1
Answers by
Son
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or