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

UserControl RadGrid Paging behaving weirdly

6 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tanuj
Top achievements
Rank 1
Tanuj asked on 22 Jul 2009, 01:24 AM
hi,
the parent is a sharepoint page, which has a webpart user control, which contains an iframe, which contains a user control that holds a radgrid control.
the radgrid has sorting filtering and paging enabled, i am using simple databinding and everything seems to work fine except the paging. lets say i have |<   <  1 2 3 4 5 >  >|   when i click on 2, the page posts back and the 2nd page is shown correctly and the number 2 is higlighted and same is the case with 3 and 4, however when i click on 1 (when the current page is 2) , both 1 and 2 are highlighted, the page does a postback but the contents are still of page 2, the next and previous arrows also exhibit the same behaviour. i am using the Black Skin and 2009.1.402.20 version., no matter what i try to do i cannot go back to page 1. this is the same behaviour in IE and FF

i have been reading couple of other threads which recommend using advanced databinding using needdatasource, i have tried that, but strangely the needdatasource method is not getting invoked automatically, the grid is blank.
when using the simple databinding i called the ShowListings() method from page_init(), but i commented those lines, because of the needdatasource method.

please advise.

here is my source code

 

<telerik:RadGrid ID="gvListing" runat="server" Skin="C21Skin" EnableEmbeddedSkins="False" AllowSorting="True" SortingSettings-SortedBackColor="#303030" EnableViewState="true"

 

 

AllowPaging="True" GridLines="None" AutoGenerateColumns="False" AllowFilteringByColumn="true" OnInit="gvListing_Init" OnNeedDataSource="gvListing_NeedDataSource"

 

 

Width="450px" Height="765px" PageSize="10" ShowStatusBar="True" FilterItemStyle-HorizontalAlign="Left" OnItemDataBound="gvListing_ItemDataBound" >

 

 

<PagerStyle Mode="NextPrevAndNumeric" Wrap="False" AlwaysVisible="true" Position="TopAndBottom"></PagerStyle>

 

 

<MasterTableView TableLayout="Fixed">

 

 

<Columns>

 

 

<telerik:GridTemplateColumn UniqueName="Select" Display="true" HeaderText="" ItemStyle-Width="8px"

 

 

ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="8px" HeaderStyle-HorizontalAlign="Center" ItemStyle-Wrap="true"

 

 

AllowFiltering="FALSE">

 

 

<ItemTemplate>

 

 

<asp:CheckBox runat="server" ID="chkSelectListing" OnCheckedChanged="chkSelectListing_OnCheckedChanged" AutoPostBack="true" />

 

 

<asp:Label ID="lblTrKey" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Tr_key") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Image" UniqueName="Image" AllowFiltering="false" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="60px" HeaderStyle-HorizontalAlign="Center" ItemStyle-Wrap="true">

 

 

<ItemTemplate>

 

 

<div style="float:left;background-image:url('http://webservices.21online.com/public/imageresize.aspx?w=60&h=45&url=<%# DataBinder.Eval(Container.DataItem,"jpg_url") %>');background-repeat:no-repeat;width:60px;height:45px;z-index:1;vertical-align:bottom;text-align:right;">

 

 

<br/>

 

 

<div style="background-image:url('<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "TotalPhotos").ToString()) > 5 ? "/21online/images/icons/yellow.gif" : "/21online/images/icons/red.gif"%>');background-repeat:no-repeat;z-index:2;width:26px;height:29px;vertical-align:middle;text-align:center;">

 

 

<span style="font-size:10pt;font-weight:bold;color:white;line-height:25px;vertical-align:baseline;"><%# DataBinder.Eval(Container.DataItem,"TotalPhotos") %></span>

 

 

</div>

 

 

</div>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="MLS_ID" Display="true" ItemStyle-ForeColor="white"

 

 

CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="MLS_ID"

 

 

UniqueName="MLS_ID" HeaderText="MLS_ID" FilterControlWidth="40px" ItemStyle-Width="70px"

 

 

ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="70px" HeaderStyle-HorizontalAlign="Left" ItemStyle-Wrap="true">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn Display="true" ItemStyle-ForeColor="white"

 

 

SortExpression="Address" UniqueName="Address" HeaderText="Address" ItemStyle-Width="113px" AllowFiltering="FALSE"

 

 

ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="113px" HeaderStyle-HorizontalAlign="Left" ItemStyle-Wrap="true">

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblAddress" CssClass="white11" Visible="true" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Address") %>'></asp:Label>,

 

 

<asp:Label ID="lblCity" CssClass="white11" Visible="true" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"city") %>'></asp:Label>,

 

 

<asp:Label ID="lblState" CssClass="white11" Visible="true" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"state") %>'></asp:Label>,

 

 

<asp:Label ID="lblZip" CssClass="white11" Visible="true" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"zip") %>'></asp:Label>

 

 

<asp:Label ID="lblImageURL" CssClass="white11" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"jpg_url") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="ListingType" Display="true" ItemStyle-ForeColor="white"

 

 

CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="ListingType"

 

 

UniqueName="ListingType" HeaderText="Type" FilterControlWidth="10px" ItemStyle-Width="40px"

 

 

ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Left" ItemStyle-Wrap="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="Price" Display="true" ItemStyle-ForeColor="white"

 

 

CurrentFilterFunction="GreaterThan" AutoPostBackOnFilter="true" SortExpression="Price"

 

 

UniqueName="Price" HeaderText="Price" FilterControlWidth="45px" ItemStyle-Width="75px" DataFormatString="{0:c0}"

 

 

ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="75px" HeaderStyle-HorizontalAlign="Left" ItemStyle-Wrap="true">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

<ClientSettings EnableRowHoverStyle="true">

 

 

<Scrolling SaveScrollPosition="true" UseStaticHeaders="true" AllowScroll="true" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

and here is the code behind

 

 

protected void gvListing_Init(object sender, System.EventArgs e)

 

{

 

GridFilterMenu menu = gvListing.FilterMenu;

 

 

int i = 0;

 

 

while (i < menu.Items.Count)

 

{

 

if (menu.Items[i].Text == "NoFilter" ||

 

menu.Items[i].Text ==

"Contains" ||

 

menu.Items[i].Text ==

"DoesNotContain" ||

 

menu.Items[i].Text ==

"StartsWith" ||

 

menu.Items[i].Text ==

"EndsWith" ||

 

menu.Items[i].Text ==

"EqualTo" ||

 

menu.Items[i].Text ==

"NotEqualTo" ||

 

menu.Items[i].Text ==

"GreaterThan" ||

 

menu.Items[i].Text ==

"LessThan"

 

 

 

 

)

{

 

switch (menu.Items[i].Text)

 

{

 

case "NoFilter":

 

{

menu.Items[i].Text =

"No Filter";

 

 

break;

 

}

 

case "Contains":

 

{

menu.Items[i].Text =

"Contains";

 

 

break;

 

}

 

case "DoesNotContain":

 

{

menu.Items[i].Text =

"Does Not Contain";

 

 

break;

 

}

 

case "StartsWith":

 

{

menu.Items[i].Text =

"Starts With";

 

 

break;

 

}

 

case "EndsWith":

 

{

menu.Items[i].Text =

"Ends With";

 

 

break;

 

}

 

case "EqualTo":

 

{

menu.Items[i].Text =

"Equal To";

 

 

break;

 

}

 

case "NotEqualTo":

 

{

menu.Items[i].Text =

"Not Equal To";

 

 

break;

 

}

 

case "GreaterThan":

 

{

menu.Items[i].Text =

"Greater Than";

 

 

break;

 

}

 

case "LessThan":

 

{

menu.Items[i].Text =

"Less Than";

 

 

break;

 

}

}

i++;

}

 

else

 

 

 

 

{

menu.Items.RemoveAt(i);

}

}

}

 

protected void gvListing_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 

{

 

 

if (ListingsDS.Tables[0].Rows.Count > 0)

 

{

gvListing.DataSource = ListingsDS.Tables[0];

 

if (CrestNote.Visible == false)

 

{

gvListing.MasterTableView.Columns[4].HeaderText =

"";

 

}

}

 

else

 

 

 

 

{

lblNoOfListings.Text =

"The category you have selected does not require listings.";

 

}

}

 

private void ShowListings()

 

{

 

if (ListingsDS.Tables[0].Rows.Count > 0)

 

{

gvListing.DataSource = ListingsDS.Tables[0];

gvListing.DataBind();

 

if (CrestNote.Visible == false)

 

{

 

//gvListing.Columns[4].Display = false;

 

 

 

 

gvListing.MasterTableView.Columns[4].HeaderText =

"";

 

}

}

 

else

 

 

 

 

{

lblNoOfListings.Text =

"The category you have selected does not require listings.";

 

}

}

 

 

public void chkSelectListing_OnCheckedChanged(object sender, EventArgs e)

 

{

 

CheckBox cb = (CheckBox)sender;

 

 

GridDataItem item = (GridDataItem)cb.NamingContainer;

 

 

Label lblTKey = (Label)item["Select"].FindControl("lblTrKey");

 

 

Label lblAddress = (Label)item["Address"].FindControl("lblAddress");

 

 

Label lblCity = (Label)item["Address"].FindControl("lblCity");

 

 

Label lblState = (Label)item["Address"].FindControl("lblState");

 

 

Label lblZip = (Label)item["Address"].FindControl("lblZip");

 

 

Label lblImageURL = (Label)item["Address"].FindControl("lblImageURL");

 

 

string strTrKey = lblTKey.Text;

 

 

string strTrKeyAddress = lblAddress.Text + ", " + lblCity.Text + ", " + lblState.Text + " " + lblZip.Text;

 

 

string strTrKeyImg = lblImageURL.Text;

 

 

eCampaign_Cart nlList_cart;

 

nlList_cart = CartSession;

 

if (cb.Checked == true)

 

{

nlList_cart.AddOrModifyMember(

new eCampaign_CartItem(strTrKey, strTrKeyAddress, strTrKeyImg));

 

}

 

else

 

 

 

 

{

nlList_cart.DeleteMember(strTrKey);

}

CartSession = nlList_cart;

divCartItemCount.InnerHtml = nlList_cart.getPrintNumberOfItems();

 

}

 

protected void gvListing_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

{

 

if (e.Item is GridDataItem)

 

{

 

GridDataItem item = e.Item as GridDataItem;

 

 

string strTrKey = ((Label)item["Select"].FindControl("lblTrKey")).Text;

 

 

bool bSelected = false;

 

 

if (CartSession != null)

 

{

bSelected = CartSession.FindTrKeySelected(strTrKey);

 

if (bSelected)

 

{

 

CheckBox cb = (CheckBox)item["Select"].FindControl("chkSelectListing");

 

cb.Checked =

true;

 

}

}

}

}

6 Answers, 1 is accepted

Sort by
0
Tanuj
Top achievements
Rank 1
answered on 23 Jul 2009, 02:39 AM
any updates for this please?
0
Pavel Trnka
Top achievements
Rank 1
answered on 23 Jul 2009, 02:33 PM
Hello,

I'm experiencing similar problem with RadGrid in UserControl in Sharepoint site.

I have used RadGrids many many times with both approach so databinding technics are quite known to me.

In this weird scenario I get blank grid when I want to sort data by clicking on header column. The same problem with paging.

Absolutely don't get it, NeedDataSource event is not fired, but e.g. PreRender event works fine.

Very very weird. And in addition this usercontrol is used on several places and somewhere paging and sorting work very well.

Pavel

0
Yavor
Telerik team
answered on 27 Jul 2009, 06:37 AM
Hello Pavel,

Based on the supplied information, it is hard to determine what is causing the issue at hand. If the issue persists, you can open a formal support ticket, and supply a small code sample, for additional review and testing.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Richard
Top achievements
Rank 1
answered on 25 Apr 2012, 04:28 PM
Was this ever resolved? I am experiencing the same phenomena.

Half an hour later: I suspect this might be to do with a conflict between filtering and paging...
Three quarters of an hour later: Maybe not....
0
Maria Ilieva
Telerik team
answered on 30 Apr 2012, 11:38 AM
Hi Richard,

As the previous post are rather old and we have made different modification in our RadGrid control, I would suggest you to open a regular support ticket and send us sample runnable application which demonstrates the issue you are currently facing. Thus we will be able to debug it locally and do our best to isolate the root cause of the problem you are facing.

Kind regards,
Maria Ilieva
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
Celestyn
Top achievements
Rank 1
answered on 25 Oct 2012, 06:05 PM
I solved similar behavior by wrapping the RadGrid user control inside asp:Panel. Then in RadAjaxManager ajaxify just this panel.
<Template>
<asp:Panel ....>
<uc:withRadGridInside />
</asp:Panel>
</Template>
Tags
Grid
Asked by
Tanuj
Top achievements
Rank 1
Answers by
Tanuj
Top achievements
Rank 1
Pavel Trnka
Top achievements
Rank 1
Yavor
Telerik team
Richard
Top achievements
Rank 1
Maria Ilieva
Telerik team
Celestyn
Top achievements
Rank 1
Share this question
or