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

Pagination Problem In Radgrid very Important Fix

4 Answers 332 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nagendra
Top achievements
Rank 1
nagendra asked on 06 Jan 2011, 09:43 AM
Hi ,

I am not able to see the radgrid pagination at the first instance when the grid gets load.. when radgrid gets binded for the second time we are able to see the pagination. Please gives the solution for this wierd problem ....

Please find the screenshot attached screen shot.

In the Frist Scrren shot paging is not visible properly...

In the Second ScreenShot Paging gets visible properly.


We are Setting the page size in the code behiend on page load event.
<telerik:RadGrid ID="rgCostBasisInquiry" runat="server" AllowMultiRowSelection="false"
                                AllowPaging="true" OnPreRender="rgCostBasisInquiry_PreRender" ShowHeader="true"
                                AutoGenerateColumns="False" loadingtemplatetransparency="25" OnNeedDataSource="rgCostBasisInquiry_NeedDataSource"
                                Width="750px" OnItemDataBound="rgCostBasisInquiry_ItemDataBound" GridLines="None"
                                AllowSorting="True" OnItemCommand="rgCostBasisInquiry_ItemCommand"
                                Height="235px" AlternatingItemStyle-BackColor="AliceBlue" Skin="Office2007">
                                <AlternatingItemStyle BackColor="AliceBlue"></AlternatingItemStyle>
                                <MasterTableView TableLayout="Fixed" Name="CBInquiryGrid" DataKeyNames="SecurityMasterID"
                                    EnableNoRecordsTemplate="true">
                                    <PagerStyle Mode="NextPrevAndNumeric" Visible="true" />
                                    <NoRecordsTemplate>
                                        <div>
                                            No records to display</div>
                                    </NoRecordsTemplate>
                                    <ParentTableRelation>
                                        <telerik:GridRelationFields MasterKeyField="SecurityMasterID" />
                                    </ParentTableRelation>
                                    <NestedViewTemplate>
                                        <asp:Panel runat="server" ID="InnerContainer" Visible="false">
                                            <telerik:RadGrid AllowMultiRowSelection="false" AllowPaging="false" ID="rgCBInquiryChildGrid"
                                                runat="server" Skin="Office2007" ShowHeader="true" Width="96%" OnItemDataBound="rgCBInquiryChildGrid_ItemDataBound"
                                                AutoGenerateColumns="False" loadingtemplatetransparency="25" OnNeedDataSource="rgCBInquiryChildGrid_NeedDataSource"
                                                GridLines="None" AllowSorting="True" Height="140px" AlternatingItemStyle-BackColor="AliceBlue">
                                                <AlternatingItemStyle BackColor="AliceBlue"></AlternatingItemStyle>
                                                <MasterTableView TableLayout="Fixed" Name="CBInquiryChildGrid" EnableNoRecordsTemplate="true">
                                                    <Columns>
                                                        <telerik:GridTemplateColumn DataField="SecurityMasterID" HeaderButtonType="TextButton"
                                                            HeaderText="SecurityMasterID" SortExpression="SecurityMasterID" UniqueName="SecurityMasterID"
                                                            Visible="false">
                                                            <HeaderStyle HorizontalAlign="left" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblSecurityMasterID" Text='<%# DataBinder.Eval(Container.DataItem, "SecurityMasterID")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="ParentLotID" HeaderButtonType="TextButton"
                                                            HeaderText="ParentLotID" SortExpression="ParentLotID" UniqueName="ParentLotID"
                                                            Visible="false">
                                                            <HeaderStyle HorizontalAlign="left" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblParentLotID" Text='<%# Convert.ToInt64(DataBinder.Eval(Container.DataItem, "ParentLotID"))%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="TradeNumber" HeaderButtonType="TextButton"
                                                            HeaderText="Trade #" SortExpression="TradeNumber" UniqueName="TradeNumber">
                                                            <HeaderStyle HorizontalAlign="center" Width="50px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="hlTradeNumber" Font-Underline="true" ForeColor="Blue" ToolTip="Click here to view Cost Basis Detail screen"
                                                                    runat="server" Text='<%# ((DataBinder.Eval(Container.DataItem, "TradeNumber") == null) || (DataBinder.Eval(Container.DataItem, "TradeNumber") == "")) ? " " : DataBinder.Eval(Container.DataItem, "TradeNumber")%>'></asp:LinkButton>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="TaxLotID" HeaderButtonType="TextButton" HeaderText="Lot ID"
                                                            SortExpression="TaxLotID" UniqueName="TaxLotID">
                                                            <HeaderStyle HorizontalAlign="center" Width="50px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="hlLotID" Font-Underline="true" ForeColor="Blue" ToolTip="Click here to view Cost Basis Detail screen"
                                                                    runat="server" Text='<%#Convert.ToInt64(DataBinder.Eval(Container.DataItem, "TaxLotID")) %>'></asp:LinkButton>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="MatchedLotID" HeaderButtonType="TextButton"
                                                            HeaderText="Match Lot ID" SortExpression="MatchedLotID" UniqueName="MatchedLotID">
                                                            <HeaderStyle HorizontalAlign="center" Width="50px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="hlMatchedLotID" Font-Underline="true" ForeColor="Blue" ToolTip="Click here to view Cost Basis Detail screen"
                                                                    runat="server" Text='<%#Convert.ToInt64(DataBinder.Eval(Container.DataItem, "MatchedLotID")) %>'></asp:LinkButton>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridBoundColumn DataField="TradeDate" DataType="System.DateTime" HeaderButtonType="TextButton"
                                                            HeaderText="Trade Date" SortExpression="TradeDate" UniqueName="TradeDate" DataFormatString="{0:MM/dd/yyyy}">
                                                            <HeaderStyle HorizontalAlign="center" Width="55px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridTemplateColumn DataField="TradeType" HeaderButtonType="TextButton" HeaderText="Trade Type"
                                                            SortExpression="TradeType" UniqueName="TradeType">
                                                            <HeaderStyle HorizontalAlign="center" Width="85px" />
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblTradeType" Text='<%# DataBinder.Eval(Container.DataItem, "TradeType")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridBoundColumn DataField="Quantity" HeaderButtonType="TextButton" HeaderText="Qty"
                                                            SortExpression="Quantity" UniqueName="Quantity">
                                                            <HeaderStyle HorizontalAlign="center" Width="40px" />
                                                            <ItemStyle HorizontalAlign="Right" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridTemplateColumn DataField="Price" HeaderButtonType="TextButton"
                                                            HeaderText="Price" SortExpression="Price" UniqueName="Price">
                                                            <HeaderStyle HorizontalAlign="center" Width="60px" />
                                                            <ItemStyle HorizontalAlign="Right" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblPrice" Text='<%# DataBinder.Eval(Container.DataItem, "Price")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="MarketValue" HeaderButtonType="TextButton"
                                                            HeaderText="Market Value" SortExpression="MarketValue" UniqueName="MarketValueChld">
                                                            <HeaderStyle HorizontalAlign="center" Width="70px" />
                                                            <ItemStyle HorizontalAlign="Right" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblMarketValue" Text='<%# DataBinder.Eval(Container.DataItem, "MarketValue")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="CostBasis" HeaderButtonType="TextButton" HeaderText="Cost Basis"
                                                            SortExpression="" UniqueName="CostBasis">
                                                            <HeaderStyle HorizontalAlign="center" Width="70px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <telerik:RadNumericTextBox ID="txtCostBasis" Font-Size="xx-small" runat="server"
                                                                    Width="95%" Value='<%# Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "CostBasis"))%>'>
                                                                </telerik:RadNumericTextBox>
                                                                <asp:HiddenField ID="hdnCostBasisChldChdStatus" runat="server" Value="0" />
                                                                <asp:HiddenField ID="hdnCostBasisOldValue" runat="server" Value='<%# Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "CostBasis"))%>' />
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="UnrealisedGainLoss" HeaderButtonType="TextButton"
                                                            HeaderText="Unrealized Gain/Loss" SortExpression="UnrealisedGainLoss" UniqueName="UnrealisedGainLoss">
                                                            <HeaderStyle HorizontalAlign="center" Width="70px" />
                                                            <ItemStyle HorizontalAlign="Right" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblUnrealisedGainLoss" Text='<%# DataBinder.Eval(Container.DataItem, "UnrealisedGainLoss")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="RealisedGainLoss" HeaderButtonType="TextButton"
                                                            HeaderText="Realized Gain/Loss" SortExpression="RealisedGainLoss" UniqueName="RealisedGainLoss">
                                                            <HeaderStyle HorizontalAlign="center" Width="70px" />
                                                            <ItemStyle HorizontalAlign="Right" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblRealisedGainLoss" Text='<%# DataBinder.Eval(Container.DataItem, "RealisedGainLoss")%>'></asp:Label>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridBoundColumn DataField="GainLossTerm" HeaderButtonType="TextButton" HeaderText="Term"
                                                            SortExpression="GainLossTerm" UniqueName="GainLossTerm">
                                                            <HeaderStyle HorizontalAlign="center" Width="40px" />
                                                            <ItemStyle HorizontalAlign="Center" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn DataField="ClosedDate" DataType="System.DateTime" HeaderButtonType="TextButton"
                                                            HeaderText="Closed Date" SortExpression="ClosedDate" UniqueName="ClosedDate"
                                                            DataFormatString="{0:MM/dd/yyyy}">
                                                            <HeaderStyle HorizontalAlign="center" Width="55px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn DataField="AcquisitionDate" DataType="System.DateTime" HeaderButtonType="TextButton"
                                                            HeaderText="Acquisition Date" SortExpression="AcquisitionDate" UniqueName="AcquisitionDate"
                                                            DataFormatString="{0:MM/dd/yyyy}">
                                                            <HeaderStyle HorizontalAlign="center" Width="65px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridTemplateColumn DataField="LotType" HeaderButtonType="TextButton"
                                                            HeaderText="Lot Type" SortExpression="LotType" UniqueName="LotType">
                                                            <HeaderStyle HorizontalAlign="center" Width="90px" />
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblLotType" Text='<%# DataBinder.Eval(Container.DataItem, "LotType")%>' Visible="false"></asp:Label>
                                                                <telerik:RadComboBox ID="cmdLotType" Width="80px" runat="server" Skin="Office2007"
                                                                    ToolTip="Select Lot Type" ></telerik:RadComboBox>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="CostBasisType" HeaderButtonType="TextButton" Visible="false"
                                                            HeaderText="Cost Basis Type" SortExpression="CostBasisType" UniqueName="CostBasisType">
                                                            <HeaderStyle HorizontalAlign="center" Width="0px" />
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblCostBasisType" Text='<%# DataBinder.Eval(Container.DataItem, "CostBasisType")%>' Visible="false"></asp:Label>
                                                                <telerik:RadComboBox ID="cmdCostBasisType" Width="80px" runat="server" Skin="Office2007"
                                                                    ToolTip="Select Cost Basis Type"></telerik:RadComboBox>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                        <telerik:GridTemplateColumn DataField="Action" HeaderButtonType="TextButton" HeaderText="Action"
                                                            SortExpression="Action" UniqueName="Action">
                                                            <HeaderStyle HorizontalAlign="center" Width="45px" />
                                                            <ItemStyle HorizontalAlign="left" />
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="hlAction" Font-Underline="true" ForeColor="Blue" ToolTip="Click here to view Update Lot screen"
                                                                    runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Action") %>'></asp:LinkButton>
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                                    </Columns>
                                                </MasterTableView>
                                                <ClientSettings AllowExpandCollapse="true">
                                                    <Scrolling AllowScroll="true" ScrollHeight="50px" UseStaticHeaders="true" />
                                                    <Selecting AllowRowSelect="false" />
                                                </ClientSettings>
                                            </telerik:RadGrid>
                                        </asp:Panel>
                                    </NestedViewTemplate>
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="SecurityMasterID" HeaderButtonType="TextButton"
                                            Visible="false" HeaderText="SecurityMasterID" SortExpression="SecurityMasterID"
                                            UniqueName="SecurityMasterID">
                                            <HeaderStyle HorizontalAlign="left" Width="0px" />
                                            <ItemStyle HorizontalAlign="left" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn DataField="AccountMasterID" HeaderButtonType="TextButton"
                                            HeaderText="AccountMasterID" UniqueName="AccountMasterID" Visible="false">
                                            <HeaderStyle HorizontalAlign="left" />
                                            <ItemStyle HorizontalAlign="left" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblAccountMasterID" Text='<%# DataBinder.Eval(Container.DataItem, "AccountMasterID")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="Symbol" HeaderButtonType="TextButton" HeaderText="Symbol"
                                            SortExpression="Symbol" UniqueName="Symbol">
                                            <HeaderStyle HorizontalAlign="center" Width="60px" />
                                            <ItemStyle HorizontalAlign="Center" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblSymbol" Text='<%# DataBinder.Eval(Container.DataItem, "Symbol")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="CUSIP" HeaderButtonType="TextButton" HeaderText="CUSIP"
                                            SortExpression="CUSIP" UniqueName="CUSIP">
                                            <HeaderStyle HorizontalAlign="center" Width="70px" />
                                            <ItemStyle HorizontalAlign="Center" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblCUSIP" Text='<%# DataBinder.Eval(Container.DataItem, "CUSIP")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="Description" HeaderButtonType="TextButton"
                                            HeaderText="Description" UniqueName="Description">
                                            <HeaderStyle HorizontalAlign="center" Width="160px" />
                                            <ItemStyle HorizontalAlign="left" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblDescription" Text='<%# DataBinder.Eval(Container.DataItem, "Description")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="SecurityType" HeaderButtonType="TextButton"
                                            HeaderText="Sec.Type" SortExpression="SecurityType" UniqueName="SecurityType" Visible="false">
                                            <HeaderStyle HorizontalAlign="center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblSecurityType" Text='<%# DataBinder.Eval(Container.DataItem, "SecurityTypeCode")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn DataField="Quantity" HeaderButtonType="TextButton" HeaderText="Quantity"
                                            SortExpression="Quantity" UniqueName="Quantity">
                                            <HeaderStyle HorizontalAlign="Center" Width="65px" />
                                            <ItemStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn DataField="MarketValue" HeaderButtonType="TextButton"
                                            HeaderText="Market Value" SortExpression="MarketValue" UniqueName="MarketValueParent">
                                            <HeaderStyle HorizontalAlign="center" Width="85px" />
                                            <ItemStyle HorizontalAlign="Right" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblMarketValue" Text='<%# DataBinder.Eval(Container.DataItem, "MarketValue")%>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="UnRealisedGainLoss" HeaderButtonType="TextButton"
                                            HeaderText="Unrealized Gain/Loss" SortExpression="UnRealisedGainLoss" UniqueName="UnRealisedGainLoss">
                                            <HeaderStyle HorizontalAlign="center" Width="85px" />
                                            <ItemStyle HorizontalAlign="Right" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblUnrealisedGainLoss" Text='<%# DataBinder.Eval(Container.DataItem, "UnRealisedGainLoss") %>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="RealisedGainLoss" HeaderButtonType="TextButton"
                                            HeaderText="Realized Gain/Loss" SortExpression="RealisedGainLoss" UniqueName="RealisedGainLoss">
                                            <HeaderStyle HorizontalAlign="center" Width="85px" />
                                            <ItemStyle HorizontalAlign="Right" />
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblRealisedGainLoss" Text='<%# DataBinder.Eval(Container.DataItem, "RealisedGainLoss") %>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn DataField="Action" HeaderButtonType="TextButton" HeaderText="Action"
                                            UniqueName="Action">
                                            <HeaderStyle HorizontalAlign="Center" Width="40px" />
                                            <ItemStyle HorizontalAlign="Center" />
                                            <ItemTemplate>
                                                <asp:ImageButton ID="hlAddTaxLot" ToolTip="Click here to add Tax Lot" ImageUrl="~/Skins/Office2007/Grid/AddRecord.gif"
                                                    runat="server" />                                               
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                    </Columns>
                                </MasterTableView>
                                <ClientSettings AllowExpandCollapse="true">
                                    <Scrolling AllowScroll="True" ScrollHeight="50px" UseStaticHeaders="true" />
                                    <Selecting AllowRowSelect="false" />
                                </ClientSettings>
                                <FilterMenu NotSelectedImageUrl="~/Skins/GridSkin/Ice/NotSelectedMenu.gif" SelectedImageUrl="~/Skins/GridSkin/Ice/SelectedMenu.gif">
                                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                </FilterMenu>
                            </telerik:RadGrid>



4 Answers, 1 is accepted

Sort by
0
nagendra
Top achievements
Rank 1
answered on 10 Jan 2011, 07:55 AM
Hi,

   Please reply to the issue as early as possible.

Thanks,
Nagendra
0
Pavlina
Telerik team
answered on 10 Jan 2011, 12:56 PM
Hello Nagendra,

I reviewed the provided code, and it looks correct. Can you please send us the code-behind file so we can check if there are any problems there?

Kind regards,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
nagendra
Top achievements
Rank 1
answered on 11 Jan 2011, 02:14 PM

protected void Page_Load(object sender, EventArgs e)

        {

            StringBuilder logedInUsrInfo = null;

            try

            {

                Log.Init();

                logedInUsrInfo = new StringBuilder();

                LoadDataFromSession();

                currencySymbol = ConfigurationManager.AppSettings["CurrencySymbol"].ToString();

                internalUser = ConfigurationManager.AppSettings["InternalUser"].ToString();

                pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["InquiryDefaultPageSize"]);

                sessionExpireScript = "alert('Session has expired. Please re-login.');";

                if (loggedInUserType == ConstantsAndEnumsCostBasis.WebUserType.Firm)

                {

                    if (Page.IsPostBack)

                    {

                        //set defaults

                        errMessages.InnerText = String.Empty;

                        if (!txtCustAcctNo.Text.Equals(string.Empty))

                        {

                            btnCustAcctGo.Enabled = true;

                       }

                    }

                    else

                    {

                        EnableDisableControls(false);

                    }

                    rgCostBasisInquiry.PageSize = pageSize;

                }

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed in CostBasis Inquiry Page Load", Log.LogMessageType.Error, ex);

                throw;

            }

        }

        /// <summary>

        /// This method makes the controls visiblity based on the input param

        /// </summary>

        /// <param name="blnVisible"></param>

        private void EnableDisableControls(bool blnVisible)

        {

            rgCostBasisInquiry.Visible = blnVisible;

            btnGridRefresh.Visible = blnVisible;

           btnGridUpdate.Visible = blnVisible;

            btnExportToExcel.Visible = blnVisible;

            lblGridPageNotification.Visible = blnVisible;

        }

protected void rgCostBasisInquiry_ItemCommand(object source, GridCommandEventArgs e)

        {

            if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)

            {

                ((GridDataItem)e.Item).ChildItem.FindControl("InnerContainer").Visible = !e.Item.Expanded;

                if (!e.Item.Expanded)

                {

                    try

                    {

                        GridDataItem dataItem = (GridDataItem)e.Item;

                        string secMasterID = dataItem.GetDataKeyValue("SecurityMasterID").ToString();

                        Panel pnlGrid = ((GridDataItem)e.Item).ChildItem.FindControl("InnerContainer") as Panel;

                        RadGrid rgInnerGrid = pnlGrid.FindControl("rgCBInquiryChildGrid") as RadGrid;

                        rgInnerGrid.DataSource = GetChildDataObject(secMasterID);

                        rgInnerGrid.Rebind();

                    }

                    catch (Exception ex)

                    {

                        Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                        //display necessary failure error on the UI

                        ShowErrorMessage(false, string.Empty);

                    }

                }

            }

        }

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

        {

            try

            {

                if (Session["TaxLotsDetails"] == null)

                {

                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "SessionExpire", sessionExpireScript, true);

                    return;

                }

                List<CBInquiryTaxLotAggregateValues> cbTaxLot = GetParentDataObject();

                if (cbTaxLot.Count <= 0)

                {

                    EnableDisableControls(false);

                    ShowErrorMessage(false, "No Result returned by the 'Tax Lot Search' query.");

                }

                //btnGridUpdate.Visible = (cbTaxLot.Count > 0) ? true : false;

                btnExportToExcel.Visible = (cbTaxLot.Count > 0) ? true : false;

                lblGridPageNotification.Visible = true;

                if (cbTaxLot.Count > pageSize)

                {

                    lblGridPageNotification.Text = "Note: Click Update to refresh calculation and save changes.<br />'W'in front of Trade Type indicates the lot was subject to wash sale rules.<br />All changes will be lost if moved to next page without saving.";

                }

                rgCostBasisInquiry.DataSource = cbTaxLot;

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                //display necessary failure error on the UI

                ShowErrorMessage(false, string.Empty);

            }

        }

        protected void rgCostBasisInquiry_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)

        {

            try

            {

                GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

                switch (e.DetailTableView.Name)

                {

                    case "gtvCBInquiryChildGrid":

                        {

                            try

                            {

                                string secMasterID = dataItem.GetDataKeyValue("SecurityMasterID").ToString();

                                e.DetailTableView.DataSource = GetChildDataObject(secMasterID);

                                break;

                            }

                            catch (Exception ex)

                            {

                                Log.Write("Load Grid failed", Log.LogMessageType.Error, ex);

                                ShowErrorMessage(false, "Unable to Load data to Grid");

                            }

                           break;

                        }

                    default:

                        break;

                }

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                ShowErrorMessage(false, string.Empty);

            }

        }

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

        {

            try

            {

                if (Session["TaxLotsDetails"] == null)

                {

                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "SessionExpire", sessionExpireScript, true);

                    return;

                }               

                RadGrid rgInnerGrid = (source as RadGrid);

                Label lblSecurityMasterID = (source as RadGrid).MasterTableView.Items[0].FindControl("lblSecurityMasterID") as Label;//.NamingContainer) as GridNestedViewItem).Parent.Parent.Parent as RadGrid;

                string secMasterID = lblSecurityMasterID.Text;

                rgInnerGrid.DataSource = GetChildDataObject(secMasterID);

            }

           catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                ShowErrorMessage(false, string.Empty);

            }

        }

        protected void rgCBInquiryChildGrid_ItemDataBound(object sender, GridItemEventArgs e)

        {

            try

            {

                if (e.Item.OwnerTableView.Name.Equals("CBInquiryChildGrid"))

                {

                    if (e.Item is GridDataItem)

                    {

                        GridDataItem dataItem = (GridDataItem)e.Item;

                        Label labelSecurityMasterID = dataItem.FindControl("lblSecurityMasterID") as Label;

                        Label labelTradeType = dataItem.FindControl("lblTradeType") as Label;

                        string cusip = null, symbol = null;

                        RadNumericTextBox txtCostBasis = dataItem.FindControl("txtCostBasis") as RadNumericTextBox;

                        txtCostBasis.Type = NumericType.Currency;

                        txtCostBasis.NumberFormat.DecimalDigits = 2;

                        txtCostBasis.NumberFormat.DecimalSeparator = ".";

                        txtCostBasis.NumberFormat.GroupSeparator = ",";

                        txtCostBasis.NumberFormat.GroupSizes = 3;

                        txtCostBasis.NumberFormat.NegativePattern = "- $n";

                        txtCostBasis.NumberFormat.PositivePattern = "$ n";

                        txtCostBasis.Culture = new CultureInfo("en-US");

                        //Bind the RadComboboxes and set the selectedvalue

                        RadComboBox radCmbLotType = dataItem.FindControl("cmdLotType") as RadComboBox;

                        RadComboBox radCmbCostBasisType = dataItem.FindControl("cmdCostBasisType") as RadComboBox;

                        Label lblLotType = dataItem.FindControl("lblLotType") as Label;

                        Label lblCostBasisType = dataItem.FindControl("lblCostBasisType") as Label;

                        radCmbLotType.DataSource = Enum.GetNames(typeof(CBServRef.TaxLotTypes));

                        radCmbLotType.DataBind();

                        radCmbCostBasisType.DataSource = Enum.GetNames(typeof(CBServRef.CostBasisTypes));

                        radCmbCostBasisType.DataBind();

                        radCmbLotType.SelectedValue = lblLotType.Text;

                        radCmbCostBasisType.SelectedValue = lblCostBasisType.Text;

                        //Add onclick attribute to hyperlinks in child rows

                        string tradeType = labelTradeType.Text.Trim().Replace("W - ", String.Empty);

                        Label labelParentLotID = dataItem.FindControl("lblParentLotID") as Label;

                        LinkButton buttonTradeNumber = dataItem.FindControl("hlTradeNumber") as LinkButton;

                        buttonTradeNumber.Attributes.Add("onclick", "javascript:ShowDetailForm('" + labelParentLotID.Text + "','ParentLotID','" + buttonTradeNumber.Text + "','" + tradeType + "','" + txtCostBasis.Text + "','" + lblLotType.Text + "','InquiryScreen'); return false;");

                        LinkButton buttonLotID = dataItem.FindControl("hlLotID") as LinkButton;

                        buttonLotID.Attributes.Add("onclick", "javascript:ShowDetailForm('" + buttonLotID.Text + "','LotID','0','" + labelTradeType.Text + "','" + txtCostBasis.Text + "','" + lblLotType.Text + "','InquiryScreen'); return false;");

                        LinkButton buttonMatchedLotID = dataItem.FindControl("hlMatchedLotID") as LinkButton;

                        buttonMatchedLotID.Attributes.Add("onclick", "javascript:ShowDetailForm('" + buttonMatchedLotID.Text + "','MatchedLotID','0','" + ReverseBuySellCode(tradeType) + "','" + txtCostBasis.Text + "','" + lblLotType.Text + "','InquiryScreen'); return false;");

                        if (rblSymbolCusip.SelectedValue.Equals("S"))

                        {

                            if (!txtSymbolCusip.Text.Equals(string.Empty))

                                symbol = txtSymbolCusip.Text;

                        }

                        else

                        {

                            if (!txtSymbolCusip.Text.Equals(string.Empty))

                                cusip = txtSymbolCusip.Text;

                        }

                        LinkButton buttonAction = dataItem.FindControl("hlAction") as LinkButton;

                        buttonAction.Attributes.Add("onclick", "javascript:ShowUpdateTaxLot('" + buttonLotID.Text + "','" + buttonMatchedLotID.Text + "','" + labelSecurityMasterID.Text + "','" + buttonAction.Text + "','" + labelTradeType.Text + "'); return false;");

                        HiddenField hdnCostBasisOldValue = dataItem.FindControl("hdnCostBasisOldValue") as HiddenField;

                        HiddenField hdnCostBasisChldChdStatus = dataItem.FindControl("hdnCostBasisChldChdStatus") as HiddenField;

                        txtCostBasis.Attributes.Add("OnBlur", "return CostBasisModified('" + txtCostBasis.ClientID + "','" + hdnCostBasisOldValue.ClientID + "','" + hdnCostBasisChldChdStatus.ClientID + "')");

                        LinkButton linkBtnTradeNumber = dataItem.FindControl("hlTradeNumber") as LinkButton;

                        LinkButton linkBtnLotID = dataItem.FindControl("hlLotID") as LinkButton;

                        LinkButton linkBtnMatchedLotID = dataItem.FindControl("hlMatchedLotID") as LinkButton;

                        ChangeLinkButtonTextAndColor(linkBtnTradeNumber);

                        ChangeLinkButtonTextAndColor(linkBtnLotID);

                        ChangeLinkButtonTextAndColor(linkBtnMatchedLotID);

                        Label labelMarketValue = dataItem.FindControl("lblMarketValue") as Label;

                        Label labelRealized = dataItem.FindControl("lblRealisedGainLoss") as Label;

                        Label labelUnrealized = dataItem.FindControl("lblUnrealisedGainLoss") as Label;

                        Label labelPrice = dataItem.FindControl("lblPrice") as Label;

                        //Adding $ currency symbol to all the money field

                        if (!labelPrice.Text.Equals("&nbsp;") && !labelPrice.Text.Equals(string.Empty))

                        {

                            decimal priceValue = Convert.ToDecimal(labelPrice.Text);

                            labelPrice.Text = FormatCurrency(priceValue);

                        }

                       if (!labelMarketValue.Text.Equals("&nbsp;") && !labelMarketValue.Text.Equals(string.Empty))

                        {

                            decimal marketValue = Convert.ToDecimal(labelMarketValue.Text);

                            labelMarketValue.Text = FormatCurrency(marketValue);

                        }

                        if (!labelUnrealized.Text.Equals("&nbsp;") && !labelUnrealized.Text.Equals(string.Empty))

                        {

                            decimal unrealisedValue = Convert.ToDecimal(labelUnrealized.Text);

                            labelUnrealized.Text = FormatCurrency(unrealisedValue);

                        }

                        if (!labelRealized.Text.Equals("&nbsp;") && !labelRealized.Text.Equals(string.Empty))

                        {

                            decimal realisedValue = Convert.ToDecimal(labelRealized.Text);

                            labelRealized.Text = FormatCurrency(realisedValue);

                        }

                       //Fill blank to the fields having zero                                   

                        if (labelMarketValue != null && labelTradeType != null

                            && (labelMarketValue.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0")

                                || labelMarketValue.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0.00"))

                            && !((labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("Buy") || labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("ShortSell"))

                                    && (linkBtnMatchedLotID.Text.Trim().Equals("&nbsp;"))))

                        {

                            labelMarketValue.Text = "&nbsp;";

                        }

                        if (labelRealized != null && labelTradeType != null

                            && (labelRealized.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0")

                                || labelRealized.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0.00"))

                            && !(labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("Sell")

                                || labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("BuyToCover")))

                        {

                            labelRealized.Text = "&nbsp;";

                        }

                        if (labelUnrealized != null && labelTradeType != null

                            && (labelUnrealized.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0")

                                || labelUnrealized.Text.Replace(currencySymbol, String.Empty).Trim().Equals("0.00"))

                            && !((labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("Buy") || labelTradeType.Text.Replace("W -", String.Empty).Trim().Equals("ShortSell"))

                                    && (linkBtnMatchedLotID.Text.Trim().Equals("&nbsp;"))))

                        {

                            labelUnrealized.Text = "&nbsp;";

                        }

                        //Change the color to green for +ve and red for -ve

                        ChangeForeColor(labelRealized);

                        ChangeForeColor(labelUnrealized);

                        if (userInfo[4] != null && userInfo[4].Equals("2"))

                        {

                            radCmbLotType.Enabled = true;

                            radCmbCostBasisType.Enabled = true;

                            txtCostBasis.Enabled = true;

                            radCmbLotType.OnClientSelectedIndexChanged = "LotTypeSelectedIndexChanged";

                            radCmbCostBasisType.OnClientSelectedIndexChanged = "CostBasisSelectedIndexChanged";

                        }

                        else

                        {

                            txtCostBasis.Enabled = false;

                            radCmbLotType.Enabled = false;

                            radCmbCostBasisType.Enabled = false;

                        }

                    }

                }

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                ShowErrorMessage(false, string.Empty);

            }

        }

        protected void rgCostBasisInquiry_ItemDataBound(object sender, GridItemEventArgs e)

        {

           try

            {

                if (e.Item.OwnerTableView.Name.Equals("CBInquiryGrid"))

                {

                    if (e.Item is GridDataItem)

                    {

                        GridDataItem dataItem = (GridDataItem)e.Item;

                        ImageButton buttonAddTaxLot = dataItem.FindControl("hlAddTaxLot") as ImageButton;

                        Label labelAccountMasterID = dataItem.FindControl("lblAccountMasterID") as Label;

                        Label labelCusip = dataItem.FindControl("lblCUSIP") as Label;

                        Label labelSymbol = dataItem.FindControl("lblSymbol") as Label;

                        Label labelDescription = dataItem.FindControl("lblDescription") as Label;

                        Label labelSecurityType = dataItem.FindControl("lblSecurityType") as Label;

                        //Add onclick attribute to hyperlink hlAddTaxLot

                        if (loggedInUserType == ConstantsAndEnumsCostBasis.WebUserType.Firm)

                        {

                            buttonAddTaxLot.Attributes.Add("onclick", "javascript:ShowAddTaxLot('" + labelCusip.Text + "','" +

                               labelSymbol.Text + "','" + labelDescription.Text + "','" + labelSecurityType.Text + "','" + labelAccountMasterID.Text + "'); return false;");

                        }

                        else

                        {

                            buttonAddTaxLot.ImageUrl = "~/Skins/Office2007/Grid/DisableAddRecord.gif";

                            buttonAddTaxLot.ToolTip = "User not allowed to Add Tax Lot";

                            buttonAddTaxLot.Enabled = false;

                        }

                    }

                }

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                //display necessary failure error on the UI

                ShowErrorMessage(false, string.Empty);

            }

        }

        /// <summary>

        /// This method replaces 0 with &nbsp; and change the forecolor to White

        /// </summary>

        /// <param name="linkButton"></param>

        private void ChangeLinkButtonTextAndColor(LinkButton linkButton)

        {

            if (linkButton != null && (linkButton.Text.Trim().Equals("0") || linkButton.Text.Trim().Equals(String.Empty)))

            {

                linkButton.Text = "&nbsp;";

                linkButton.ForeColor = Color.White;

            }

        }

        /// <summary>

        /// This method is used to color the text

        ///     Red color for -ve value

        ///     Green coloe for +ve value

        /// </summary>

        /// <param name="labelName"></param>

        private void ChangeForeColor(Label labelName)

        {

            if (!labelName.Text.Trim().Equals(String.Empty)

                && !labelName.Text.Trim().Equals("&nbsp;"))

            {

                decimal data = Convert.ToDecimal(labelName.Text.Replace(currencySymbol, String.Empty).Trim());

                if (data < 0)

                {

                    labelName.ForeColor = Color.Red;

                }

                else if (data > 0)

                {

                    labelName.ForeColor = Color.Green;

                }

            }

        }

        /// <summary>

        ///

        /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        protected void rgCostBasisInquiry_PreRender(object sender, EventArgs e)

        {

            try

            {

                foreach (GridDataItem item in rgCostBasisInquiry.MasterTableView.Items)

                {

                    if (item is GridDataItem)

                    {

                        foreach (GridColumn col in rgCostBasisInquiry.Columns)

                        {

                            //Add space to the cell that has null or empty value

                            if (!col.ColumnType.Equals("GridTemplateColumn"))

                            {

                                if (string.IsNullOrEmpty(item[col.UniqueName].Text.Trim())

                                    || item[col.UniqueName].Text.Equals("&nbsp;"))

                                {

                                    item[col.UniqueName].Text = "&nbsp;";

                                }

                            }

                           else

                            {

                                #region AllowSpaceInCols

                                Label labelName;

                                switch (col.UniqueName)

                                {

                                    case "Symbol":

                                        labelName = item.FindControl("lblSymbol") as Label;

                                        if (labelName.Text.Trim().Equals(String.Empty))

                                        {

                                            labelName.Text = "&nbsp;";

                                        }

                                        break;

                                    case "CUSIP":

                                        labelName = item.FindControl("lblCUSIP") as Label;

                                        if (labelName.Text.Trim().Equals(String.Empty))

                                        {

                                            labelName.Text = "&nbsp;";

                                        }

                                        break;

                                    case "Description":

                                        labelName = item.FindControl("lblDescription") as Label;

                                        if (labelName.Text.Trim().Equals(String.Empty))

                                        {

                                            labelName.Text = "&nbsp;";

                                        }

                                        break;

                                    case "SecurityType":

                                        labelName = item.FindControl("lblSecurityType") as Label;

                                        if (labelName.Text.Trim().Equals(String.Empty))

                                        {

                                            labelName.Text = "&nbsp;";

                                        }

                                        break;

                                    default:

                                        break;

                                }

                                #endregion

                            }

                        }

                    }

                }

            }

            catch (Exception ex)

            {

                Log.Write("Execution failed", Log.LogMessageType.Error, ex);

                ShowErrorMessage(false, string.Empty);

            }

        }

 

 

Code Behind File
0
Pavlina
Telerik team
answered on 14 Jan 2011, 01:29 PM
Hello Nagendra,

I suggest that you try using the code for the page size inside "(!Page.IsPostBack") of the Page_Load event and see if it makes any difference.

Additionally, if the problem persists I will ask you to open a formal support ticket and send us some test project we can debug locally.

Greetings,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
nagendra
Top achievements
Rank 1
Answers by
nagendra
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or