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

RadDataPager is going back to the first selected page in response.redirecting!

3 Answers 93 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
shemein
Top achievements
Rank 1
shemein asked on 27 May 2014, 08:57 AM
Hello,

I have used RadDataPager as the navigation bar of my web pages. in RadDataPager1_PageIndexChanged event in MasterPage I have used Response.Redirect to the url of new page to navigate the webpages. everything is working well except the selected page that is going back to 1 in the RadDatapager. I need to highlight the page number that the user is in  after Response.Redirect to that page. It sounds that Response.Redirect is refreshing the MasterPage and causes the content pages work individualy. Would you please help me to fix it?

My code is:

​ protected void RadDataPager1_PageIndexChanged(object sender, RadDataPagerPageIndexChangeEventArgs e)
{


DataTable dt = (DataTable) Session["PageDetails"];
int[] PageNumber = (dt.AsEnumerable().Select(s => s.Field<int>("PageNumber"))).ToArray();
string[] pageUrlStrings = (dt.AsEnumerable().Select(f => f.Field<string>("CurrentPage"))).ToArray();
                
                 Label1.Text = Convert.ToString(e.NewStartRowIndex + 1);

for (int i = 0; i < PageNumber.Length; i++)
{

if (PageNumber[i] == Convert.ToInt32(Label1.Text))
{

                        
                            Response.Redirect(pageUrlStrings[i]);



}

}

}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 May 2014, 12:25 PM
Hi shemein,

Please try the below C# code snippet open a page in new window.

C#:
protected void ProductsListDataPager_PageIndexChanged(object sender, Telerik.Web.UI.RadDataPagerPageIndexChangeEventArgs e)
{
    string url = "http://www.telerik.com";
    Response.Write("<script>window.open('" + url + "');</script>");
}

Thanks,
Princy.
0
shemein
Top achievements
Rank 1
answered on 30 May 2014, 06:21 AM
Hi Princy,

Thanks for your reply but my point wasn't about it. I mean when page is posting back the selected page in raddatapage will be again number 1. I want to know how I can remove the selected highlighting  from the first page that is by default?
another question: why when I create the buttons as IButtons in creating controls and use the button.postback="URL"  the url doesn't change the address in the toolbar but also it goes to the end of the first page like this:
http://localhost:/ section/entity.aspx ~/section/glob.aspx
Would you please help me? I really need to know about it. It has taken several days but no result:(
0
Princy
Top achievements
Rank 2
answered on 30 May 2014, 07:09 AM
Hi shemein,

The below sample code snippet will highlight the correct page after postback, this is the default behavior of the control.

ASPX:
<telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server" DataSourceID="SqlDataSource1" ItemPlaceholderID="ProductsHolder" DataKeyNames="ProductID">
           <LayoutTemplate>
               <fieldset style="max-width: 920px;" id="FieldSet1">
                   <legend>Products</legend>
                   <asp:Panel ID="ProductsHolder" runat="server" />
                   <table cellpadding="0" cellspacing="0" width="100%;" style="clear: both;">
                       <tr>
                           <td>
                               <telerik:RadDataPager runat="server" ID="ProductsListDataPager"  PagedControlID="RadListView1"  onpageindexchanged="ProductsListDataPager_PageIndexChanged">
                                   <Fields>
                                       <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                       <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                       <telerik:RadDataPagerPageSizeField PageSizes="9,18,27,45" />
                                       <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                   </Fields>
                               </telerik:RadDataPager>
                           </td>
                       </tr>
                   </table>
               </fieldset>
           </LayoutTemplate>
           <ItemTemplate>
               <div style="float: left;">
                   <table cellpadding="0" cellspacing="0" style="width: 230px; height: 118px">
                       <tr>
                           <td style="width: 20%;">
                               Name:
                           </td>
                           <td style="width: 80%; padding-left: 5px;">
                               <%# Eval("ProductName") %>
                           </td>
                       </tr>
                   </table>
               </div>
           </ItemTemplate>
       </telerik:RadListView>

C#:
protected void ProductsListDataPager_PageIndexChanged(object sender, Telerik.Web.UI.RadDataPagerPageIndexChangeEventArgs e)
   {
       string url = "http://www.telerik.com";
       Response.Write("<script>window.open('" + url + "');</script>");
   }

I am not sure about your second requirement, please elaborate your requirement.

Thanks,
Princy.
Tags
DataPager
Asked by
shemein
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
shemein
Top achievements
Rank 1
Share this question
or