Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objectdatasource not working unless specify defaultvalue of param

Status
Not open for further replies.

zerkat

Programmer
Jul 12, 2007
103
US
This should be simple -

I have a gridview on my web page with a dropdown that is bound to an ObjectDataSource. The ObjectDataSource has a SelectMethod with a TypeName that points to a DAL. The function inside the DAL is asking for a parameter to pass to Access to perform the query. I used asp:formParameter to specify what control to pass to the adapter to use as a parameter but it's not working. No error, nothing - the dropdown just doesn't get populated unless I give my formParameter a DefaultValue.

My code looks like this:

<asp:DropDownList runat="server" ID="drpTask" DataSourceID="dsDrpTask" DataValueField="Pkey" DataTextField="TaskName" AppendDataItems="true"></asp:dropDownlist>

After the gridview:

<asp:ObjectDataSource ID="DsDrpTask" runat="server" SelectMethod="GetTaskNameByPosition" TypeName="TaskAdapter">
<selectParameters>
<asp:FormParameter FormField="drpPosition" Name="intPkey" Type="Int32" />
</selectparameters>
</asp:ObjectDataSource>

I am not sure what's going on - I have tried several variations of this and it's the only one that has come close to actually working. I did a response.write on the drpPosition.selectedvalue and it's coming back with a value.
The drpPosition is being populated in the code behind on the Page_Load event.
 
just don't use ObjectDataSource. it is not debugable (none of the datasource controls are because they are all markup)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top