繁体   English   中英

当数据源是具有查询参数的域数据源并且还启用了分页时,如何获取网格视图的总行数?

[英]How to get total rows count of grid view while data source is domain data source with query parameters and paging is also enabled?

代码如下。 我能够获得IQueryable类型的集合,但我也想获得总行数。

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="dsBiz"
                AutoGenerateColumns="False" ShowHeader="false"
                DataKeyNames="PinCodeId" PageSize="5" OnDataBound="GV_DataBound">
            </asp:GridView>
            <asp:DomainDataSource ID="dds" runat="server" QueryName="GetPinCodeInfoList" DomainServiceTypeName="postoffice.Controller.Biz">
                <QueryParameters>
                    <asp:ControlParameter ControlID="ddlState" Name="stateId" PropertyName="SelectedValue" />
                    <asp:ControlParameter ControlID="ddlDistrict" Name="district" PropertyName="SelectedValue" />
                    <asp:ControlParameter ControlID="ddlTaluka" Name="taluk" PropertyName="SelectedValue" />
                </QueryParameters>
            </asp:DomainDataSource>

为此,我在方法“GetPinCodeInfoList”返回值之前在 HttpContext 中添加了计数值,然后在需要的地方使用。

                ` //Added Count in the context
            HttpContext.Current.Items.Add("Count", count);
            //update that value wherever required
            HttpContext.Current.Items["Count"] = count;
            //Access that value anywhere in same context
            String countString = HttpContext.Current.Items["Count"].ToString();`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM