471,595 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

ObjectDataSource: Value of session variable never passed to defined SelectMethod

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<FunVideoGetFunVideoListNewest(int startRowIndex,
int maximumRows)

Any clue?

Thanks,
Roger

Jan 7 '07 #1
1 9631
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
Roger schrieb:
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<FunVideoGetFunVideoListNewest(int startRowIndex,
int maximumRows)

Any clue?

Thanks,
Roger
Jan 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ole M | last post: by
4 posts views Thread by Anne Catterick | last post: by
3 posts views Thread by mthomason | last post: by
1 post views Thread by Jürgen Bayer | last post: by
1 post views Thread by =?Utf-8?B?cm9zczYxMw==?= | last post: by
reply views Thread by =?Utf-8?B?UGF1bA==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.