ObjectDataSource: Value of session variable never passed to defined SelectMethod

R

Roger

Hi all

On a page I am using a repeater which is linked to an ObjectDataSource
(same page):

<asp:Repeater ID="VideoListNewestRepeater" runat="server"
DataSourceID="VideoListNewestDataSource">

The code for ObjectDataSource looks like this:

<asp:ObjectDataSource ID="VideoListNewestDataSource" runat="server"
EnablePaging="True"
SelectCountMethod="GetCountRowsTotal"
SelectMethod="GetFunVideoListNewest" TypeName="BLL.FunVideo">
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="startRowIndex"
SessionField="StartRowIndex"
Type="Int32" />
<asp:SessionParameter DefaultValue="4" Name="maximumRows"
SessionField="MaximumRows"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

SelectMethod GetFunVideoListNewest is a static function of object
BLL.FunVideo (business layer, different project). This function has two
parameters: int startRowIndex, int maximumRows. As you can see, for
both parameters session variables are defined.

In a separate function which is triggered by click event of a
LinkButton (same page) the session variables are set and/or updated and
the select command of ObjectDataSource gets invoked.

LinkButtonNewestRight_Click:
int newestStartRowIndex = 0;
if (Session["StartRowIndex"] != null)
{
newestStartRowIndex = (int)Session["StartRowIndex"];
}
newestStartRowIndex += 4;
Session["StartRowIndex"] = newestStartRowIndex;
Session["MaximumRows"] = 4;
this.VideoListNewestDataSource.Select();
this.VideoListNewestRepeater.DataBind();

But there is the problem that for both parameters of function
GetFunVideoListNewest always only value 0 gets passed!!! The values of
session variables and the default values are not taken into account!

The signature of the invoked function looks like this:
public static List<FunVideo> GetFunVideoListNewest(int startRowIndex,
int maximumRows)

Any clue?

Thanks,
Roger
 
R

Roger

I found out what was the problem:
<asp:ObjectDataSource ID="VideoListNewestDataSource" runat="server"
EnablePaging="True" ...

EnablePaging of ObjectDataSource should not be set to true when using
custom paging! I have just removed this attribute and it works!

Regards,
Roger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top