如何获取网格视图的总行数,而数据源是具有查询参数和分页的域数据源也是如何启用的?

时间:2016-10-03 08:48:40

标签: c#

代码如下。我能够获得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>

1 个答案:

答案 0 :(得分:1)

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

                ` //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();`