.net - ObjectDataSource Paging -> no data displayed in GridView -
i have objectdatasource , gridview configured shown below (using vs2008 w/ .net3.5):
<asp:objectdatasource id="odsmaindata" runat="server" enablepaging="true" oldvaluesparameterformatstring="original_{0}" selectmethod="getmaindata" typename="errorviewer.model.errorviewmodel" selectcountmethod="countmaindata"> <selectparameters> <asp:parameter name="maximumrows" type="int32" /> <asp:parameter name="startrowindex" type="int32" /> </selectparameters> </asp:objectdatasource> <asp:gridview id="grdmaindata" runat="server" allowpaging="true" datasourceid="odsmaindata" pagesize="15" allowsorting="true"> </asp:gridview>
there no eventhandlers or other code in code behind gridview or datasource
so there methods in underlying class "errorviewmodel": public datatable getmaindata() { var dt = provider.maindata(); mymaindata = dt; return dt; }
public datatable getmaindata(int maximumrows, int startrowindex) { var dt = provider.maindata(); mymaindata = dt; return dt; } public long countmaindata() { var count = provider.getmaindatacount(); return count; } public long countmaindata(int maximumrows, int startrowindex) { var count = countmaindata(); return count; }
what want: custom server side paging. problem: when set enablepaging=true in datasource, there no data displayed in gridview. if enablepaging set false, there data displayed. can see, 2 methods retrieving data same. debugging shows, there rows returned when using enablepaging=true. strange thing (using enablepaging=true): in getmaindata maximumrows set 15 , startrowindex 0 in countmaindata maximumrows set 0 , startrowindex 0
i've implemented type of custom paging in project , did same configuration - time resides in strange behavior. wrong in implementation? did forgot 1 little setting? suggestions?
the mistake was, countmaindata didn't return integer. after changed countmaindata return integer, worked fine.
Comments
Post a Comment