本文介绍了使用objectdatasource在gridview中排序,起始行索引恢复为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
有谁能够帮助我.我有一个使用对象数据源的网格视图.我有分页.让我说我在第3页上.每当我点击排序列链接之一时,起始行索引就会恢复为0.这将我指向第1页,而不是第3页.有人可以帮助我吗?
< asp:GridView ID =" gvCategory" ="span> runat =" 服务器" AutoGenerateColumns =" 错误" AllowPaging =" 真实" DataSourceID =" objDs" EnableSortingAndPagingCallbacks =" True" ShowFooter =" 真实" AllowSorting =" True" OnRowCommand =" gvCategory_RowCommand" 宽度 =" 100%" OnRowDataBound =" gvCategory_RowDataBound" > < 列 > < asp:TemplateField HeaderText =" #" HeaderStyle-Width =" 2%" HeaderStyle-HorizontalAlign = " 左" HeaderStyle-字体下划线 =" false" > < ItemTemplate > <%#((((GridView)((GridViewRow)Container).Parent.Parent).PageIndex)*((GridView)((GridViewRow)Container).Parent .Parent).PageSize+ Container.DataItemIndex + 1 %> < asp:HiddenField ID =" hdfID" runat =" 服务器" 值 =' <%#Eval(" ID" )%> ' / > < /ItemTemplate > < HeaderStyle 字体下划线 =" 错误" HorizontalAlign =" 左" 宽度 =" 2%" / > < /asp:TemplateField > < asp:BoundField 数据字段 =" 类别名称" HeaderText =" 类别名称" SortExpression =" 类别名称" / > < asp:BoundField 数据字段 =" CategoryDescription" HeaderText =" 类别说明" SortExpression =" 类别描述" / > < asp:BoundField DataField =" StatusDesc" HeaderText =" 状态" SortExpression =" StatusDesc" / > < asp:TemplateField HeaderStyle-字体-下划线 =" false" HeaderStyle-Width =" 5%" ShowHeader =" 错误" > < ItemTemplate > < asp:LinkButton ID =" lnkGvSelect" runat =" 服务器" CausesValidation =" 错误" CommandArgument =' <%#Eval(" ID" )%> ' CommandName =" 选择" / > < /ItemTemplate > < HeaderStyle 字体下划线 =" 错误" 宽度 =" 5 %" / > < /asp:TemplateField > < /列 > < EmptyDataTemplate > < asp:Label ID =" lblNoAvailableData" runat =" 服务器" SkinID =" GridViewNoDataAvailable" 文本 =" 未找到记录" > < /asp:Label > < /EmptyDataTemplate > < /asp:GridView > < asp:ObjectDataSource ID =" objDs" TypeName =" IFBS .Web.Course.Maint.UI.GridViewListingClass" SelectMethod =" BindGrid" 短跑 =" 服务器" span> SelectCountMethod =" GetGridRowCount" EnablePaging =" true" StartRowIndexParameterName =" StartRow" MaximumRowsParameterName =" PageSize" SortParameterName =" SortBy" > < SelectParameters > < asp:ControlParameter 名称 =" srchTxt" ControlID =" txtSearch" PropertyName =" 文本" / > < asp:ControlParameter 名称 =" pgIdx" ControlID =" gvCategory" PropertyName =" PageIndex" / > < /SelectParameters >
在此先感谢
prasharvi
解决方案
这篇关于使用objectdatasource在gridview中排序,起始行索引恢复为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!