如何在数据源为域数据源时获得网格视图的总行数,并启用查询参数和分页
本文关键字:数据源 启用 查询 分页 参数 视图 网格 | 更新日期: 2023-09-27 18:11:19
代码如下:我能够获得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();`