Visual Basic >
Using Forums Forums
>
Off-Topic Posts (Do Not Post Here)
>
passing an object as a parameter in ObjectDataSource
passing an object as a parameter in ObjectDataSource
- I have a ObjectDataSource on a page which I am using to populated a GridView. The SelectMethod of the ObjectDataSource accepts a single parameter of TypeclsPerformSearchCriteria.
The problem I am having is that I have effectively hacked the ObjectDataSource to get it to behave properly and I was wondering if there was perhaps a more elegant way to achieve what I'm after.
The aspx script:
And that seems to required to pick up changes on the controls but then I effectively scrap the values in the code behind:<asp:ObjectDataSource ID="PerformSearchDataSource" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="PerformSearchTo_OnlyResultsData" TypeName="CurrentAccountsWebServiceCalls"> <SelectParameters> <asp:ControlParameter ControlID="txtPageNo" Name="p_PageNo" DefaultValue="0" Type="Int32" /> <asp:ControlParameter ControlID="ddlOrderByOption" Name="p_OrderByOption" DefaultValue="1" Type="Int32" /> <asp:ControlParameter ControlID="elbAccountType" PropertyName="EnumeratorValue" Name="p_AccountType" DefaultValue="1" /> <asp:ControlParameter ControlID="txtResultsPerPage" Name="p_ResultsPerPage" DefaultValue="10" Type="Int32" /> <asp:ControlParameter ControlID="chkPackagedAccountOnlyTick" Name="p_chkPackagedAccountOnlyTick" Type="Int32" /> <asp:ControlParameter ControlID="ddlOrderByOption" Name="p_BestBuyOption" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource>
As I said this code does what I need it to, only it feels a tad "Hacky" if anyone suggest a more elegant solution I'd be greatfull.Protected Sub PerformSearchDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles PerformSearchDataSource.Selecting Dim SearchCriteria As CurrentAccountsWebService.clsPerformSearchCriteria Try SearchCriteria = New CurrentAccountsWebService.clsPerformSearchCriteria SearchCriteria.PageNo = CInt(txtPageNo.Text) SearchCriteria.OrderByOption = CType(Me.ddlOrderByOption.SelectedValue, CurrentAccountsWebService.OrderByOption) SearchCriteria.AccountType = CType(Me.elbAccountType.EnumeratorValue, CurrentAccountsWebService.AccountTypes) SearchCriteria.ResultsPerPage = CInt(txtResultsPerPage.Text) SearchCriteria.PackagedAccountOnlyTick = CInt(chkPackagedAccountOnlyTick.Checked) SearchCriteria.BestBuyOption = CType(ddlBestBuyOption.SelectedValue, CurrentAccountsWebService.BestBuyOption) e.InputParameters.Clear() e.InputParameters("p_Criteria") = SearchCriteria Catch ex As Exception Throw End Try End Sub
Regards
Paul- Moved byMartin Xie - MSFTMSFT, ModeratorMonday, November 09, 2009 8:56 AMRedirect to ASP.NET forums for better support. (From:Visual Basic General)
All Replies
- Shameless bump.
You'll need to post it at http://forums.asp.net for quicker and better responses, where ASP.NET experts live in.
ASP.NET Forums » General ASP.NET » Data Presentation Controls Forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


