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

RadGrid - cannot get paging working

4 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
K
Top achievements
Rank 1
K asked on 29 Mar 2012, 05:50 PM
I have a RadGrid and am trying to get paging working with an ObjectDataSource. I have used the demo as the basis as well as a number of other forum postings, but can't seem to get the paging to display or work. RadGrid does not seem to ever call the SelectCountMethod, so I returned the totalRows and set the VirtualItemCount in the Selected event. The PageSize never gets passed into the MaximumRows in the ODS so I set the MaximumRows in the Selecting event. I have pasted the code below. If you guys need I will try to isolate a test project to reproduce, but I was hoping you might be able to discern what I am missing (I am guessing it is something obvious) by looking at the code. Unfortunately I cannot get the code snippet tool to work (probably our overly restrictive proxy) so the code is pasted below:


ucLoanSearch.ascx:

<%

 

@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucLoanSearch.ascx.cs" Inherits="VHIWebSite.Controls.ucLoanSearch" %>

 

<%

 

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<

 

 

script type="text/javascript" language="javascript">

 

</

 

 

script>

 

<

 

 

telerik:RadScriptManager ID="ScriptManager" runat="server" />

 

<

 

 

asp:ObjectDataSource ID="SearchByNameObjectDataSource" EnablePaging="true"

 

 

 

SelectCountMethod="SearchByNameCount" SortParametername="SortColumns"

 

 

 

MaximumRowsParameterName = "maximumRows" StartRowIndexParameterName="startRowIndex"

 

 

 

TypeName="TellerBL.TellerDataObjects" SelectMethod="SearchByName"

 

 

 

EnableCaching="false" runat="server"

 

 

 

onselecting="SearchByNameObjectDataSource_Selecting"

 

 

 

onselected="SearchByNameObjectDataSource_Selected">

 

<

 

 

SelectParameters>

 

 

 

<asp:Parameter Name="mspDataConnectString" Type="String" />

 

 

 

<asp:Parameter Name="clientCode" Type="String" />

 

 

 

<asp:Parameter Name="firstName" Type="String" />

 

 

 

<asp:Parameter Name="lastName" Type="String" />

 

 

 

<asp:Parameter Name="totalRows" Direction="Output" Type="Int32" />

 

</

 

 

SelectParameters>

 

</

 

 

asp:ObjectDataSource>

 

<

 

 

asp:ObjectDataSource ID="SearchByAddressObjectDataSource" EnablePaging="true" SelectCountMethod="SearchByAddressCount" SortParametername="SortColumns"

 

 

 

TypeName="TellerBL.TellerDataObjects" SelectMethod="SearchByAddress" EnableCaching="false" runat="server"

 

 

 

onselecting="SearchByAddressObjectDataSource_Selecting">

 

<

 

 

SelectParameters>

 

 

 

<asp:Parameter Name="mspDataConnectString" Type="String" />

 

 

 

<asp:Parameter Name="clientCode" Type="String" />

 

 

 

<asp:Parameter Name="houseNumber" Type="String" />

 

 

 

<asp:Parameter Name="street" Type="String" />

 

 

 

<asp:Parameter Name="city" Type="String" />

 

 

 

<asp:Parameter Name="state" Type="String" />

 

 

 

<asp:Parameter Name="zipCode" Type="String" />

 

</

 

 

SelectParameters>

 

</

 

 

asp:ObjectDataSource>

 

<

 

 

table cellspacing="0" cellpadding="0">

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1"

 

 

 

SelectedIndex="0" CssClass="TabStrip" ontabclick="RadTabStrip1_TabClick"

 

 

 

CausesValidation="False" ClickSelectedTab="True">

 

 

 

<Tabs>

 

 

 

<telerik:RadTab Text="Loan Number" Selected="True">

 

 

 

</telerik:RadTab>

 

 

 

<telerik:RadTab Text="Borrower/Co-Borrower">

 

 

 

</telerik:RadTab>

 

 

 

<telerik:RadTab Text="Property Address">

 

 

 

</telerik:RadTab>

 

 

 

</Tabs>

 

 

 

</telerik:RadTabStrip>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

 

 

<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0"

 

 

 

CssClass="PageView">

 

 

 

<telerik:RadPageView ID="LoanNumberPageView" runat="server">

 

 

 

<table cellspacing="0" cellpadding="0" style="padding-left:10px;padding-top:10px">

 

 

 

<tr valign="top">

 

 

 

<td colspan="4">

 

 

 

<asp:Label ID="LoanNumberLabel" runat="server" Text="Label">Loan Number:</asp:Label>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<asp:TextBox ID="LoanNumberTextBox" CssClass="TellerInput TellerRequired" CausesValidation="true" MaxLength="10" Width="100px" runat="server" ValidationGroup="loan"></asp:TextBox>

 

 

 

<asp:RegularExpressionValidator ID="LoanNumberRegularExpressionValidator" ValidationGroup="loan" ControlToValidate="LoanNumberTextBox" runat="server" Display="None" ValidationExpression="^\d{0,10}" ErrorMessage="Loan Number must be numeric."></asp:RegularExpressionValidator>

 

 

 

<asp:CustomValidator ValidationGroup="loan" ID="LoanNumberCustomValidator" runat="server" Display="None" ErrorMessage="Invalid Loan Number." onservervalidate="LoanNumberCustomValidator_ServerValidate"></asp:CustomValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;&nbsp;&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:Button id="SearchButton" runat="server" CssClass="TellerInput" UseSubmitBehavior="false" Text="Go" onclick="SearchButton_Click" ValidationGroup="loan" CausesValidation="True" />

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td colspan="4">

 

 

 

<asp:ValidationSummary ID="LoanNumberValidationSummary" DisplayMode="BulletList" runat="server" ValidationGroup="loan" SkinID="TellerSkin" />

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</telerik:RadPageView>

 

 

 

<telerik:RadPageView ID="NamePageView" runat="server" DefaultButton="NameSearchButton">

 

 

 

<div id="nameDiv" runat="server">

 

 

 

<table cellspacing="0" cellpadding="0" style="padding-left:10px;padding-top:10px">

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<asp:Label ID="LastNameLabel" runat="server">Last</asp:Label>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:Label ID="FirstNameLabel" runat="server">First</asp:Label>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<asp:TextBox ID="LastNameTextBox" CssClass="TellerInput TellerRequired" CausesValidation="true" MaxLength="10" Width="150px" runat="server" ValidationGroup="name"></asp:TextBox>

 

 

 

<asp:RegularExpressionValidator ID="LastNameRegularExpressionValidator" ValidationGroup="name" ControlToValidate="LastNameTextBox" runat="server" Display="None" ValidationExpression="^[a-zA-Z]{2,}$" ErrorMessage="Please enter at least two characters for Last Name."></asp:RegularExpressionValidator>

 

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="name" ControlToValidate="LastNameTextBox" runat="server" Display="None" ErrorMessage="Please enter a Last Name."></asp:RequiredFieldValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="FirstNameTextBox" CssClass="TellerInput" CausesValidation="true" MaxLength="10" Width="150px" runat="server" ValidationGroup="name"></asp:TextBox>

 

 

 

</td>

 

 

 

<td>&nbsp;&nbsp;&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:Button id="NameSearchButton" runat="server" CssClass="TellerInput"

 

 

 

UseSubmitBehavior="false" Text="Search"

 

 

 

onclick="NameSearchButton_Click" ValidationGroup="name"

 

 

 

CausesValidation="True" />

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td colspan="6">

 

 

 

<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" runat="server" ValidationGroup="name" SkinID="TellerSkin" />

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</div>

 

 

 

</telerik:RadPageView>

 

 

 

<telerik:RadPageView ID="AddressPageView" runat="server" DefaultButton="PropertySearchButton">

 

 

 

<table cellspacing="0" cellpadding="0" style="padding-left:10px;padding-top:10px">

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<asp:Label ID="Label2" runat="server">H/B&nbsp;#</asp:Label>

 

 

 

</td>

 

 

 

<td>&nbsp;&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:Label ID="Label3" runat="server">Street</asp:Label>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td><asp:Label ID="Label1" runat="server">City</asp:Label></td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td><asp:Label ID="Label4" runat="server">State</asp:Label></td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td><asp:Label ID="Label5" runat="server">Zip&nbsp;Code</asp:Label></td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td>

 

 

 

<asp:TextBox ID="HouseNumberTextBox" CssClass="TellerInput" CausesValidation="true" MaxLength="10" Width="50px" runat="server" ValidationGroup="address"></asp:TextBox>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="StreetTextBox" CssClass="TellerInput TellerRequired" CausesValidation="true" MaxLength="10" Width="150px" runat="server" ValidationGroup="address"></asp:TextBox>&nbsp;

 

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="address" ControlToValidate="StreetTextBox" runat="server" Display="None" ErrorMessage="Please enter a Street Name."></asp:RequiredFieldValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="CityTextBox" CssClass="TellerInput TellerRequired" CausesValidation="true" MaxLength="10" Width="100px" runat="server" ValidationGroup="address"></asp:TextBox>&nbsp;

 

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="address" ControlToValidate="CityTextBox" runat="server" Display="None" ErrorMessage="Please enter a City."></asp:RequiredFieldValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="StateTextBox" CssClass="TellerInput TellerRequired" CausesValidation="true" MaxLength="2" Width="20px" runat="server" ValidationGroup="address"></asp:TextBox>&nbsp; <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="address" ControlToValidate="StateTextBox" runat="server" Display="None" ErrorMessage="Please enter a State."></asp:RequiredFieldValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="ZipTextBox" CssClass="TellerInput" CausesValidation="true" MaxLength="10" Width="50px" runat="server" ValidationGroup="address"></asp:TextBox>&nbsp;

 

 

 

<asp:RegularExpressionValidator ID="RegularExpressionValidator4" ValidationGroup="address" ControlToValidate="ZipTextBox" runat="server" Display="None" ValidationExpression="^[0-9]{0,5}$" ErrorMessage="Zip Code must be 5 digits."></asp:RegularExpressionValidator>

 

 

 

</td>

 

 

 

<td>&nbsp;&nbsp;</td>

 

 

 

<td>

 

 

 

<asp:Button id="PropertySearchButton" runat="server" CssClass="TellerInput"

 

 

 

UseSubmitBehavior="false" Text="Search"

 

 

 

onclick="PropertySearchButton_Click" ValidationGroup="address"

 

 

 

CausesValidation="True" />

 

 

 

</td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top" class="TellerAnnotation">

 

 

 

<td>House&nbsp;or<br />Building&nbsp;Number</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>Please use only the street name<br />(e.g. &quot;Main&quot; instead of &quot;N. Main St.&quot;)</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>&nbsp;</td>

 

 

 

<td>(5 digits only)</td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

<tr valign="top">

 

 

 

<td colspan="6">

 

 

 

<asp:ValidationSummary ID="ValidationSummary2" DisplayMode="BulletList" runat="server" ValidationGroup="address" SkinID="TellerSkin" />

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</telerik:RadPageView>

 

 

 

</telerik:RadMultiPage>

 

 

 

</td>

 

</

 

 

tr>

 

<

 

 

tr>

 

 

 

<td>

 

 

 

<telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1"

 

 

 

runat="server">

 

 

 

<AjaxSettings>

 

 

 

<telerik:AjaxSetting AjaxControlID="RadGrid1">

 

 

 

<UpdatedControls>

 

 

 

<telerik:AjaxUpdatedControl ControlID="SearchResultsRadGrid" />

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

 

</AjaxSettings>

 

 

 

</telerik:RadAjaxManager>

 

 

 

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">

 

 

 

</telerik:RadAjaxLoadingPanel>

 

 

 

<telerik:RadGrid runat="server" ID="SearchResultsRadGrid"

 

 

 

AutoGenerateColumns="False" Visible="False"

 

 

 

EnableHeaderContextMenu="True" AllowSorting="True" BorderStyle="Solid"

 

 

 

CellSpacing="0" GridLines="None" BorderWidth="1px" BorderColor="Black"

 

 

 

onitemcommand="SearchResultsRadGrid_ItemCommand"

 

 

 

AllowCustomPaging="False" PageSize ="10"

 

 

 

AllowPaging="True" GroupingEnabled="False" EnableLinqExpressions="false" >

 

 

 

<clientsettings allowcolumnsreorder="False"

 

 

 

allowgroupexpandcollapse="False" reordercolumnsonclient="False"

 

 

 

enablepostbackonrowclick="True">

 

 

 

<Selecting AllowRowSelect="True" enabledragtoselectrows="False"></Selecting>

 

 

 

</clientsettings>

 

 

 

<PagerStyle AlwaysVisible="true" Mode="NumericPages"></PagerStyle>

 

 

 

<mastertableview allowpaging="False" commanditemdisplay="None" OverrideDataSourceControlSorting="True" CanRetrieveAllData="false"

 

 

 

datakeynames="Id, LoanNo" insertitempageindexaction="ShowItemOnCurrentPage"

 

 

 

grouploadmode="Server" GroupsDefaultExpanded="False">

 

 

 

<commanditemsettings exporttopdftext="Export to PDF" />

 

 

 

<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

 

 

 

<rowindicatorcolumn filtercontrolalttext="Filter RowIndicator column"

 

 

 

visible="True">

 

 

 

</rowindicatorcolumn>

 

 

 

<expandcollapsecolumn filtercontrolalttext="Filter ExpandColumn column"

 

 

 

visible="True">

 

 

 

</expandcollapsecolumn>

 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn DataField="BorrowerName" UniqueName="BorrowerName" HeaderText="Borrower" >

 

 

 

<ItemStyle Wrap="False"/>

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="BorrowerSSNFormatted" UniqueName="BorrowerSSNFormatted" HeaderText="Borrower&nbsp;SSN" >

 

 

 

<ItemStyle Wrap="False"/>

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="CoBorrowerName" UniqueName="CoBorrowerName" HeaderText="Co-Borrower" >

 

 

 

<ItemStyle Wrap="False"/>

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="CoBorrowerSSNFormatted" UniqueName="CoBorrowerSSNFormatted" HeaderText="Co&#8209;Borrower&nbsp;SSN" >

 

 

 

<ItemStyle Wrap="False"/>

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="PropertyAddress" UniqueName="PropertyAddress" HeaderText="Property&nbsp;Address" >

 

 

 

<ItemStyle Wrap="False"/>

 

 

 

</telerik:GridBoundColumn>

 

 

 

</Columns>

 

 

 

<editformsettings>

 

 

 

<editcolumn filtercontrolalttext="Filter EditCommandColumn column">

 

 

 

</editcolumn>

 

 

 

</editformsettings>

 

 

 

</mastertableview>

 

 

 

<filtermenu enableimagesprites="False">

 

 

 

</filtermenu>

 

 

 

</telerik:RadGrid>

 

 

 

</td>

 

</

 

 

tr>

 

</

 

 

table>

 




ucLoanSearch.ascx.cs:

using

 

 

System;

 

using

 

 

System.Collections.Generic;

 

using

 

 

System.Linq;

 

using

 

 

System.Web;

 

using

 

 

System.Web.UI;

 

using

 

 

System.Web.UI.WebControls;

 

using

 

 

TellerBL;

 

using

 

 

DmiCore.DataAccess;

 

using

 

 

System.Configuration;

 

using

 

 

System.Web.Profile;

 

using

 

 

DMI.UserManagement;

 

using

 

 

Dmi.Extensions;

 

using

 

 

Telerik.Web.UI;

 

 

namespace

 

 

VHIWebSite.Controls

 

{

 

 

public partial class ucLoanSearch : System.Web.UI.UserControl

 

{

 

 

const string CLIENTCODE = "ClientCode";

 

 

 

const string CUSTOMERID = "CustomerId";

 

 

 

const string GOTO_PAGE = "~/TellerWeb/LoanSummary.aspx";

 

 

 

public string ClientCode

 

{

 

 

get

 

{

 

 

Object o = ViewState[CLIENTCODE];

 

 

 

if (o == null)

 

 

 

if (PopulateClientCustInfo())

 

 

 

return ViewState[CLIENTCODE].ToString();

 

 

 

return o.ToString();

 

}

 

 

set

 

{

 

 

if (!String.IsNullOrEmpty(value))

 

ViewState[CLIENTCODE] =

 

value;

 

}

}

 

 

public string CustomerId

 

{

 

 

get

 

{

 

 

Object o = ViewState[CUSTOMERID];

 

 

 

if (o == null)

 

 

 

if (PopulateClientCustInfo())

 

 

 

return ViewState[CUSTOMERID].ToString();

 

 

 

return o.ToString();

 

}

 

 

set

 

{

 

 

if (!String.IsNullOrEmpty(value))

 

ViewState[CUSTOMERID] =

 

value;

 

}

}

 

 

public string LoanNumber

 

{

 

 

get

 

{

 

 

return LoanNumberTextBox.Text;

 

}

 

 

set

 

{

LoanNumberTextBox.Text =

 

value;

 

}

}

 

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

SetDefaultFocus();

}

 

 

protected bool PopulateClientCustInfo()

 

{

 

 

User currentUser = UserManager.GetUser(HttpContext.Current.User.Identity.Name);

 

 

 

if (currentUser == null)

 

 

 

return false;

 

 

 

Customer c = CustomerManager.GetCustomer(currentUser.CustomerID);

 

 

 

if (c == null)

 

 

 

return false;

 

 

 

Client cl = ClientManager.GetClient(c.ClientID);

 

 

 

if (cl == null)

 

 

 

return false;

 

ViewState[CUSTOMERID] = c.CustomerID;

ViewState[CLIENTCODE] = cl.ClientCode;

 

 

return true;

 

}

 

 

protected void SearchButton_Click(object sender, EventArgs e)

 

{

 

 

if (Page.IsValid)

 

{

Session[

 

TellerStringConstants.TellerLoanNo] = LoanNumberTextBox.Text;

 

Response.Redirect(GOTO_PAGE);

}

}

 

 

protected void LoanNumberCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)

 

{

args.IsValid =

 

true;

 

 

 

string loanNumber = String.Empty;

 

 

 

if (!String.IsNullOrEmpty(LoanNumberTextBox.Text))

 

{

LoanNumberTextBox.Text = LoanNumberTextBox.Text.PadLeft(10,

 

'0');

 

loanNumber = LoanNumberTextBox.Text;

}

 

 

else

 

{

args.IsValid =

 

false;

 

 

 

return;

 

}

 

 

if (!loanNumber.IsValidLoanNumber())

 

{

EventLog.

 

Web.OnTellerInvalidLoanNumber(ConfigurationManager.ConnectionStrings["LoggingEntity"].ToString(),

 

 

 

"Failed parity check", true, Request.ServerVariables["remote_addr"].ToString(),

 

 

 

ConfigurationManager.AppSettings["ApplicationName"].ToString(), Page.Request.Url.AbsoluteUri, HttpContext.Current.User.Identity.Name, Session[TellerStringConstants.TellerLoanNo] != null ? Session[TellerStringConstants.TellerLoanNo].ToString() : String.Empty);

 

args.IsValid =

 

false;

 

 

 

return;

 

}

 

 

DataErrors errorCode;

 

 

 

IHeaderInfo hi = TellerDataObjects.GetHeaderInfo(ConfigurationManager.ConnectionStrings[TellerStringConstants.MspDataEntity].ToString(), loanNumber, out errorCode);

 

 

 

if (hi == null)

 

{

EventLog.

 

Web.OnTellerInvalidLoanNumber(ConfigurationManager.ConnectionStrings["LoggingEntity"].ToString(),

 

 

 

"Loan Number does not exist.", true, Request.ServerVariables["remote_addr"].ToString(),

 

 

 

ConfigurationManager.AppSettings["ApplicationName"].ToString(), Page.Request.Url.AbsoluteUri, HttpContext.Current.User.Identity.Name, loanNumber);

 

args.IsValid =

 

false;

 

 

 

return;

 

}

 

 

}

 

 

protected void SearchByNameObjectDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)

 

{

e.InputParameters[

 

"mspDataConnectString"] = ConfigurationManager.ConnectionStrings[TellerStringConstants.MspDataEntity].ToString();

 

e.InputParameters[

 

"clientCode"] = ClientCode;

 

e.InputParameters[

 

"firstName"] = FirstNameTextBox.Text;

 

e.InputParameters[

 

"lastName"] = LastNameTextBox.Text;

 

e.Arguments.MaximumRows = 10;

}

 

 

protected void SearchByAddressObjectDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)

 

{

e.InputParameters[

 

"mspDataConnectString"] = ConfigurationManager.ConnectionStrings[TellerStringConstants.MspDataEntity].ToString();

 

e.InputParameters[

 

"clientCode"] = ClientCode;

 

e.InputParameters[

 

"houseNumber"] = HouseNumberTextBox.Text;

 

e.InputParameters[

 

"street"] = StreetTextBox.Text;

 

e.InputParameters[

 

"city"] = CityTextBox.Text;

 

e.InputParameters[

 

"state"] = StateTextBox.Text;

 

e.InputParameters[

 

"zipCode"] = ZipTextBox.Text;

 

e.Arguments.MaximumRows = 10;

}

 

 

protected void SearchResultsRadGrid_ItemCommand(object sender, GridCommandEventArgs e)

 

{

 

 

if (e.CommandName == "RowClick")

 

{

 

 

GridDataItem dataItem = (GridDataItem)SearchResultsRadGrid.SelectedItems[0];

 

 

 

if (dataItem != null)

 

{

 

 

object o = dataItem.GetDataKeyValue("Id");

 

 

 

if (o == null)

 

 

 

return;

 

 

 

object os = dataItem.GetDataKeyValue("LoanNo");

 

 

 

if (os == null)

 

 

 

return;

 

Session[

 

TellerStringConstants.TellerLoanNo] = os.ToString();

 

Response.Redirect(GOTO_PAGE);

}

}

}

 

 

protected void NameSearchButton_Click(object sender, EventArgs e)

 

{

 

 

if (Page.IsValid)

 

{

SearchResultsRadGrid.DataSourceID =

 

"SearchByNameObjectDataSource";

 

SearchResultsRadGrid.Visible =

 

true;

 

SearchResultsRadGrid.DataBind();

}

}

 

 

protected void PropertySearchButton_Click(object sender, EventArgs e)

 

{

 

 

if (Page.IsValid)

 

{

SearchResultsRadGrid.DataSourceID =

 

"SearchByAddressObjectDataSource";

 

SearchResultsRadGrid.DataBind();

SearchResultsRadGrid.Visible =

 

true;

 

}

}

 

 

protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)

 

{

SearchResultsRadGrid.Visible =

 

false;

 

SetDefaultFocus();

 

 

foreach (Control ctrl in Page.Controls)

 

ClearControls(ctrl);

}

 

 

private void ClearControls(Control c)

 

{

 

 

foreach (Control ctrl in c.Controls )

 

{

 

 

if (ctrl is TextBox)

 

((

 

TextBox)(ctrl)).Text = null;

 

 

 

if (ctrl.Controls.Count > 0)

 

ClearControls(ctrl);

}

}

 

 

 

 

private void SetDefaultFocus()

 

{

 

 

switch (RadTabStrip1.SelectedIndex)

 

{

 

 

case 0:

 

Page.Form.DefaultButton = SearchButton.UniqueID;

LoanNumberTextBox.Focus();

 

 

break;

 

 

 

case 1:

 

Page.Form.DefaultButton = NameSearchButton.UniqueID;

LastNameTextBox.Focus();

 

 

break;

 

 

 

case 2:

 

Page.Form.DefaultButton = PropertySearchButton.UniqueID;

HouseNumberTextBox.Focus();

 

 

break;

 

}

}

 

 

protected void SearchByNameObjectDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)

 

{

SearchResultsRadGrid.PageSize = 10;

SearchResultsRadGrid.AllowPaging =

 

true;

 

SearchResultsRadGrid.MasterTableView.VirtualItemCount = (

 

int)e.OutputParameters["totalRows"];

 

SearchResultsRadGrid.VirtualItemCount = (

 

int)e.OutputParameters["totalRows"];

 

}

 

}

}



TellerDataObjects.cs:

 

using

 

 

System;

 

 

 

 

using

 

 

System.Collections.Generic;

 

 

 

 

using

 

 

System.ComponentModel;

 

 

 

 

using

 

 

System.Diagnostics.Contracts;

 

 

 

 

using

 

 

TellerDataAccess;

 

 

 

 

using

 

 

System.Linq;

 

 

 

 

using

 

 

System.Web.UI.WebControls;

 

 

 

 

namespace

 

 

TellerBL

 

{

[

 

DataObjectAttribute]

 

 

 

public static class TellerDataObjects

 

 

 

 

 

{

[

 

DataObjectMethodAttribute(DataObjectMethodType.Select, false)]

 

 

 

public static IHeaderInfo GetHeaderInfo(string mspDataConnectString, string loanNumber, out DataErrors errorCode)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(loanNumber));

 

errorCode =

 

DataErrors.None;

 

 

 

IHeaderInfo hi = null;

 

 

 

try

 

 

 

 

 

{

 

 

List<IGeneralLoanInfo> gli = TellerBusinessLogic.GetGeneralLoanInfo(mspDataConnectString, loanNumber);

 

 

 

if (gli != null && gli.Count > 0)

 

{

 

 

HeaderInfo hi2 = new HeaderInfo();

 

hi2.LoanNumber = loanNumber;

hi2.BankruptcyStop = gli[0].BankruptcyStop;

hi2.BillingCityAndState = gli[0].BillingCityAndState;

hi2.BillingStreetAddress = gli[0].BillingStreetAddress;

hi2.BorrowerName = gli[0].BorrowerName;

hi2.BorrowerSSN = gli[0].MortgagorSSN;

hi2.CoBorrowerName = gli[0].CoBorrowerName;

hi2.CoBorrowerSSN = gli[0].CoMortgagorSSN;

hi2.DelinquentBalance = (gli[0].DelinquentBalance.HasValue ? gli[0].DelinquentBalance.Value :

 

decimal.Zero);

 

hi2.ForeclosureStop = gli[0].ForeclosureStop;

hi2.LastApplied = gli[0].LastFullPaymentDate;

hi2.LateCharges = gli[0].LateCharges;

hi2.NextPaymentDueDate = gli[0].Duedate;

hi2.OtherFees = (gli[0].OtherFees.HasValue ? gli[0].OtherFees.Value :

 

decimal.Zero);

 

hi2.PhoneNumber = gli[0].FstTelephoneNo;

hi2.PhoneNumber2 = gli[0].SecTelephoneNo;

hi2.PropertyCity = gli[0].PropertyCity;

hi2.PropertyState = gli[0].PropertyState;

hi2.PropertyStreet = gli[0].PropertyStreet;

hi2.PropertyZipCode = gli[0].PropertyZip;

hi2.TotalMonthlyPayment = gli[0].TotalPayment;

hi2.ZipCode = gli[0].Zipcode;

hi = hi2

 

as IHeaderInfo;

 

}

}

 

 

catch

 

 

 

 

 

{ errorCode =

 

DataErrors.UnknownErrorPleaseRetry; }

 

 

 

return hi;

 

}

[

 

DataObjectMethodAttribute(DataObjectMethodType.Select, false)]

 

 

 

public static List<ILoanSearch> SearchByName(out int totalRows, string mspDataConnectString, string clientCode, string firstName, string lastName, string SortColumns, int startRowIndex, int maximumRows)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(clientCode));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(lastName));

 

 

 

List<ILoanInfoSearchResult> l = TellerBusinessLogic.SearchByName(mspDataConnectString, clientCode, firstName, lastName);

 

totalRows = l.Count;

 

 

List<ILoanSearch> l2 = l.OrderBy(x => x.BorrowerName).Select(x => new LoanSearch(x)).Skip(startRowIndex).Take(maximumRows).ToList<ILoanSearch>();

 

 

 

return l2;

 

}

[

 

DataObjectMethodAttribute(DataObjectMethodType.Select, false)]

 

 

 

public static int SearchByNameCount(string mspDataConnectString, string clientCode, string firstName, string lastName)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(clientCode));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(lastName));

 

 

 

List<ILoanInfoSearchResult> l = TellerBusinessLogic.SearchByName(mspDataConnectString, clientCode, firstName, lastName);

 

 

 

return l.Count;

 

}

[

 

DataObjectMethodAttribute(DataObjectMethodType.Select, false)]

 

 

 

public static List<ILoanSearch> SearchByAddress(out int totalRows, string mspDataConnectString, string clientCode, string houseNumber, string street, string city, string state, string zipCode, string SortColumns, int startRowIndex, int maximumRows)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(street));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(state));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(city));

 

 

 

List<ILoanInfoSearchResult> l = TellerBusinessLogic.SearchByAddress(mspDataConnectString, clientCode, houseNumber, street, city, state, zipCode);

 

totalRows = l.Count;

 

 

return l.Select(x => new LoanSearch(x)).OrderBy(x => x.PropertyAddress).Skip(startRowIndex).Take(maximumRows).ToList<ILoanSearch>();

 

}

[

 

DataObjectMethodAttribute(DataObjectMethodType.Select, false)]

 

 

 

public static int SearchByAddressCount(string mspDataConnectString, string clientCode, string houseNumber, string street, string city, string state, string zipCode)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(street));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(state));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(city));

 

 

 

List<ILoanInfoSearchResult> l = TellerBusinessLogic.SearchByAddress(mspDataConnectString, clientCode, houseNumber, street, city, state, zipCode);

 

 

 

return l.Count;

 

}

}

}

 

 



TellerBusinessLogic.cs:

 

using

 

 

System;

 

 

 

 

 

using

 

 

System.Collections.Generic;

 

 

 

 

 

using

 

 

System.Linq;

 

 

 

 

 

using

 

 

System.Text;

 

 

 

 

 

using

 

 

System.Diagnostics.Contracts;

 

 

 

 

 

using

 

 

TellerDataAccess;

 

 

 

 

 

using

 

 

System.Data;

 

 

 

 

 

using

 

 

System.ComponentModel;

 

 

 

 

 

using

 

 

DMI.Crypto;

 

 

 

 

 

using

 

 

DMI.UserManagement;

 

 

 

 

 

using

 

 

VHIWebSite;

 

 

 

 

 

using

 

 

DMI.VHI.TellerApp;

 

 

 

 

 

using

 

 

System.Configuration;

 

 

 

 

 

using

 

 

VHIDataAccess;

 

 

 

 

 

namespace

 

 

TellerBL

 

{

 

 

public static class TellerBusinessLogic

 

 

 

 

 

 

{

 

 

internal static List<ILoanInfoSearchResult> SearchByName(string mspDataConnectString, string clientCode, string firstName, string lastName)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(clientCode));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(lastName));

 

 

 

return SearchDA.SearchByName(mspDataConnectString, clientCode, firstName, lastName).ToList<ILoanInfoSearchResult>();

 

}

 

 

internal static List<ILoanInfoSearchResult> SearchByAddress(string mspDataConnectString, string clientCode, string houseNumber, string street, string city, string state, string zipCode)

 

{

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(mspDataConnectString));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(street));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(state));

 

 

 

Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(city));

 

 

 

return SearchDA.SearchByAddress(mspDataConnectString, clientCode, houseNumber, street, city, state, zipCode).ToList<ILoanInfoSearchResult>();

 

}

}

}

4 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Apr 2012, 07:42 AM
Hello,

Most probably the reason for the erroneous behavior is that you are calling DataBind() method. You should never call DataBind method when you are using advanced databinding through declarative datasource. More information about declarative datasources could be found in this help topic.

Additionally, object datasource control provides own paging mechanism, you could check this online resource for more information on how to use it.

If you don't want to use the ObjectDataSource control paging mechanism you could set only the SelectMethod property and let the RadGrid do the needed paging.

Give these suggestions a try and check whether you get the desired behavior.
Kind regards,
Andrey
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
K
Top achievements
Rank 1
answered on 09 Apr 2012, 05:03 PM
Thanks for your reply Andrey.
I did manage to spend a little more time Friday chceking out your links and playing with the RadGrid some more, but to no avail.

Since I am using a Form to specify search criteria for the ObjectDataSource (and thus the RadGrid) the DataBind would be what I would have used to get the .Net GridView to work. The OnClick event of the "Search" button kicks off the Grid via a "Visible = true" and a "DataBind()". The selecting event of the ObjectDataSource takes care of filling in the parameters.

Does the Telerik RadGrid have a different method to tell it to refresh the data?

The test I ran Friday involved setting the DatasourceID from inside the ASPX file (declaratively) and then doing only the DataBind (I tried Rebind as well) from the onClick event. That test did not work either, with the radGrid displaying the first page of results and no paging controls. Interestingly enough the radGrid also does a "fetch" of the data on the initial PageLoad, even though it is set to "Visible=False".

If you think it will help I can try to build an isolated test project for you.

Thanks!
- Kane
0
Andrey
Telerik team
answered on 10 Apr 2012, 01:21 PM
Hi,

Yes, DataBind method is used with GridView and it could be used with RadGrid also, but in case you are not using declarative datasource or NeedDataSource event.

If you are using declarative datasource or NeedDataSource event and you need to fetch again the data from the datasource you should call Rebind() method instead of DataBind().

RadGrid is always binded if a datasource is specified, no matter is its Visible property is set to true or false.

It will be best if you could isolate the project and share it on some online sharing service. Thus we will be able to help you resolve the issue faster.

Kind regards,
Andrey
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
K
Top achievements
Rank 1
answered on 11 Apr 2012, 04:32 PM
We have managed to finally figure out what was causing the problem. There is an extra paging=false in the MasterTableView. We moved all the paging attributes to the MasterTableView.and duplicated the Grid so that it runs with a rebind instead of a databind. The issues with the VirtualItemCount having to be set manually and the SelectCount method not being called were all resolved from the seetings changes and the paging now properly displaying.

For those who stumble upon this in the future, the DataObject class that contains the Select method is now non-static and contains a member variable (private property) to store the count, which is then returned via the SelectCount method.
Tags
Grid
Asked by
K
Top achievements
Rank 1
Answers by
Andrey
Telerik team
K
Top achievements
Rank 1
Share this question
or