ObjectDataSource (ODS) SelectParameter DefaultValue not being passed

S

SJL

I have a GridView (ASP.NET 2.0 + SQL Sever 2005) control that is bound to an
Object Data Source (ODS). The ODS has a SelectParameter for the sort
expression. The SelectParameter has a DefaultValue defined, however when the
page intitially loads, that DefaultValue is not passed to my SelectMethod. I
have sorting enabled, so when I do subsequent sorts on the GridView, the
pSortExpression value is passed and sorting works, but for some reason, the
default value is never used.

I can explicitly set it in the page load calling the GridView.Sort method,
but I don't see why I should have to. Any ideas why the DefaultValue of my
SelectParameters don't work?

Thanks,
SJL
 
L

lgawlik

Ok, great, I'm not going insane. I too am experiencing this issue.

I have an ODS that is working wonderfully with my SelectMethod and the
SelectParameters I've set. However, the DefaultValue for my sort
parameter (orderBy in my case) is ignored when the page is first
loaded.

I am able to sort after the pages loads, but the initial sort I
expected (based on the orderBy DefaultValue) does not occur. While
stepping through the code, I verified the parameter is not set when my
SelectMethod is called.

Anyone experience this issue and workaround it in any way?

Thanks,
LG
 
M

Manu

SJL,

I answered this on my blog:

http://www.manuelabadia.com/blog/PermaLink,guid,8e348d54-3885-48df-b491-3b0a039fb63e.aspx

The answer is this:

When the GridView needs data, a select operation is performed in the
underlying data source control. Before this operation is performed, a
method called CreateDataSourceSelectArguments is called on the
GridView. This method creates the arguments that will be passed to the
Select method of the ObjectDataSource, which in turns calls the method
specified by the property SelectMethod. In the
CreateDataSourceSelectArguments method, the SortExpression is set based
on the GridView's state and the ObjectDataSource just assign that
value to the sort parameter. So, as you can see, the DefaultValue is
never used for the sort parameter.

I hope it helps,
Manuel Abadia

SJL ha escrito:
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top