Last post Feb 01, 2011 09:00 PM by shabirhakim1
Feb 01, 2011 08:41 PM|newbie2C#|LINK
I have a text box that's used to enter search criteria such as phone number, name, id....etc. I currently have five Object Data Sources that correspond with each of the search options. The search button's click event is used to determine which search criteria
is to be used and thus which data source to use.
I question if this is the best way to do this. The only thing that's different for the five data sources is the ID, the select method and the name of the control parameter for the select parameter. I wonder if it would be better to assign the values of
these few unique properties dynamically in the code behind, since the five data sources are so similar.
Are there any performance considerations of having the five data source on the page and doing this the way I am? Would it be better to have one data source and change the unique properties in the code behind with the click event?
this is two of the five data sources:
<asp:ObjectDataSource ID="CustomerByLastNameDataSource" runat="server" SelectMethod="GetCustomerByThreeLettersOfLastName" TypeName="ClassLibrary.BAL.CustomerBAL">
<asp:ControlParameter Name="LastName" Type="String" ControlID="txtSearch" />
<asp:ObjectDataSource ID="CustomerByAddressDataSource" runat="server" SelectMethod="GetCustomerByAddress" TypeName="ClassLibrary.BAL.CustomerBAL">
<asp:ControlParameter Name="Address" Type="String" ControlID="txtSearch" />
Feb 01, 2011 09:00 PM|shabirhakim1|LINK
If performance is such a major concern for your application, you should probably create best possible solution by keeping Performance and Scalability Issues in consideration like having multiple datasources,controls,larger page size....which, performing
unnecessary initialization code on page postback, and late-bound data binding may all cause significant rendering overhead. This may decrease the perceived and true page performance.As you know Object data source has given a property to do the same, what we
are only suppose to do is justsupply the search string to filter expression property of object data source and thats all .Better to have one data source and change the unique properties in the code behind with the Event.you can also create both possible solutions,
test them and choose the one that performs best.