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;
}
}
}
}