代码如下。我可以获取集合的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();`

关于c# - 当数据源是具有查询参数的域数据源并且还启用了分页时,如何获取网格 View 的总行数?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39827665/

10-13 06:01