So I'm refactoring code for an asp.net web app. I'm new to asp.net, and was surprised to learn about the data-binding within controls. It seems nice and simple, however it also seems to be mingling data code with logic (within this implementation). My question is how to use data-binding while still keeping the queries separated from the logic. If there isn't a way to do that, what would the best practice be in accomplishing the same task?
My concrete example is the following
Originally I wanted my design to have a seperate database class to be closest to the data. A QueryFactory to store all my queries which only my DataAccess class would call. When I ran into the data-binding however, I am now calling my QueryFactory outside my DataAccess class which seems odd to me since it's not what I had intended.
thanks for your help,
Phil
My concrete example is the following
VB.NET:
'myPage.aspx.designer.vb
Protected WithEvents SqlHistoryTable As Global.System.Web.UI.WebControls.SqlDataSource
'myPage.aspx
<asp:SqlDataSource ID="SqlHistoryTable" runat="server" ProviderName="System.Data.OleDb">
</asp:SqlDataSource>
'...
<dx:ASPxGridView ID="dgrHistory" ClientInstanceName="dgrHistory" runat="server" DataSourceID="SqlHistoryTable"
Width="831px" EnableCallBacks="False" KeyFieldName="Date">
'...
'myPage.aspx.vb --->This is where my conflict with data-binding occurs<---
SqlHistoryTable.SelectCommand = QueryFactory.GetHistoryTableCommand(
Convert.ToDateTime(dtpStartDate.Text), Convert.ToDateTime(dtpEndDate.Text))
Originally I wanted my design to have a seperate database class to be closest to the data. A QueryFactory to store all my queries which only my DataAccess class would call. When I ran into the data-binding however, I am now calling my QueryFactory outside my DataAccess class which seems odd to me since it's not what I had intended.
thanks for your help,
Phil