Cannot get all rows from Rad Grid-View with DataPager

ぃ、小莉子 提交于 2019-12-13 04:27:46

问题


This is my dataGridView ,

 <telerik:RadGrid ID="grdSalaryCalculation" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    Skin="Telerik" Font-Names="Myanmar3" CellSpacing="0" EnableLinqExpressions="False"
                    OnNeedDataSource="grdSalaryCalculation_NeedDataSource" GridLines="None" ShowFooter="True"
                    PageSize="5" AllowSorting="true" OnItemDataBound="grdSalaryCalculation_ItemDataBound">
                    <ExportSettings ExportOnlyData="True" FileName="Attendance List">
                    </ExportSettings>
                    <GroupingSettings CaseSensitive="false"></GroupingSettings>
                    <MasterTableView DataKeyNames="EmpID,NRC" CommandItemDisplay="Top" AllowFilteringByColumn="true"
                        HeaderStyle-HorizontalAlign="Center" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
                        IsFilterItemExpanded="false" AllowSorting="true">
                        <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToExcelButton="true">
                        </CommandItemSettings>
                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <Columns>
                        ......
                        ......

And this is how I loop dataRow and get

        foreach (GridDataItem dataItem in grdSalaryCalculation.MasterTableView.Items)
        {

My GridView has about 20 rows , but I used PageSize=5 .
Using above code , I can get only 5 rows .
How can I get all rows (20 rows) from GridView ?


回答1:


Fixed !
Using this link , just add AllowPaging=false and true at the start and end of looping .

RadGrid1.AllowPaging = false;
RadGrid1.Rebind();

        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {

        }

RadGrid1.AllowPaging = true;
RadGrid1.Rebind();

This code can get all of rows from Data GridView with Paging !



来源:https://stackoverflow.com/questions/20657826/cannot-get-all-rows-from-rad-grid-view-with-datapager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!