Hey Again Folks,
Well, good news... I now have a working solution to the problem which has been vexxing me for a couple of weeks (in my defense, I'm new to ASP.net, C# AND DNN, so I think my learning curve has been a tad steep...)
So, the problem I had was as follows:
I have an existing backend database which contains the data I want to display. This data is relatively simple, in my opinion (but I tend to think things are simply when other people disagree, so I may not be the best judge on that), but the data is returned to the front end via stored procs, as the individual datapoints which need to be displayed simultaneously are resident in multiple tables.
I have a SEPERATE Database which contains the DNN infrastructure
I need to have the data be output into a module for display that I can skin appropriately to the page (haven't started to inject the CSS functionality yet, but it's on the agenda)
Data needs to be finessed a bit by the front end, so that in the displaying table\grid, I can have HTML links, etc, which are dynamic based on the data passed back from the stored procs.
This data is to be used for display only and will not be able to be altered by the user at any point.
(although not part of the problem, I've decided to start working in the 3.5 framework, with VS2008, against a SQL Server 2005 backend)
Now, I've bounded this around on these forums a bit, as well as had some offline emails back and forth with a couple of folks, and I have to say, the answers seemed a bit contradictory at times, as well as the fact that some of the examples I was pointed to either fell a bit short of what I needed, or were not at all applicable to my scenario.
In the end, the solution I came up with (the code for the code behind page of the ascx file is pasted at the end of this post) is as follows.
I have a single LINQ data source which contains all of the stored procs which are relevant to the 'chunk' of modules which I'm currently working on. It also has all of the tables for this 'chunk' but since I have to use multiple tables for each set of data that I'll be displaying, that doesn't work really well. As such, only the stored procs will be used at this time and they are all read only.
I take my new ascx control (which has a single literal control on it) and on page load, I retrieve my data via the stored proc in the LiNQ data source.
I then take my data and iterate through it, performing any logic as needed and build the table structure I need, appending it to a buffer string, then once I am done, I push this table into the literal control. (Eventually, I'll be integrating my CSS and replacing the table with Divs so my boss is happy)
That's all it took, and I now have my module. I've actually build a pair of these controls and have them in our test site right now, and it's working fine.
But, my question is, why does nobody do it this way? For more robust functionality, I definitely understand why the tutorials and examples are built the way they are. Most of the DNN folks out there are quite content to write the data for the module into a dedicated table in the DB created just for said module.. But, for somebody like me, who has a pre-existing backend which just needs to be exposed to the internet, I thnk that what I did works really well. I know I'm not the only one out there who has this as a business need.
Is there a specific, technical reason, why I should NOT be doing things the way I have laid out above, and show in the code below?
If I can't get a good explanation or reason, from a DNN infrastructure stand point, why what I'm doing is a bad thing, then I'm probably going to write up a tutorial for others who have the same need.
Brian
using DotNetNuke;
using System.Web.UI;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
using DotNetNuke.Security;
using System.Data.SqlClient;
using System.Data;
using DotNetNuke.Data;
public partial class DesktopModules_CollegeBasketball_TeamsByConference : DotNetNuke.Entities.Modules.PortalModuleBase
{
protected void Page_Load(object sender, System.EventArgs e)
{
string CurrentConferenceName = "";
string ConferenceParameter = Request.QueryString["ConferenceLookup"];
bool IsOddRowCount = true;
StringBuilder buffer = new StringBuilder();
CollegeBasketballDataContext Teams = new CollegeBasketballDataContext();
if (ConferenceParameter == "")
{
ConferenceParameter = null;
};
var Results = Teams.ff_GetCollegeBasketBallConferenceTeams(ConferenceParameter);
buffer.Append("<Table width='100%'>");
foreach (ff_GetCollegeBasketBallConferenceTeamsResult CurrRow in Results)
{
if (CurrentConferenceName.ToString() == CurrRow.ConferenceName.ToString())
{
}
else
{
buffer.Append("<th bgcolor='CornflowerBlue' colspan = 4 >");
buffer.Append(CurrRow.ConferenceName);
buffer.Append("</th>");
buffer.Append("<tr>");
buffer.Append("<td>");
buffer.Append("<b><u>Team Name</u></b>");
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("<b><u>Statistics</u></b>");
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("<b><u>Schedule</u></b>");
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("<b><u>Players</u></b>");
buffer.Append("</td>");
buffer.Append("</tr>");
buffer.Append("</tr>");
CurrentConferenceName = CurrRow.ConferenceName;
};
if (IsOddRowCount == true)
{
buffer.Append("<tr bgcolor='LightGray' >");
IsOddRowCount = false;
}
else
{
buffer.Append("<tr bgcolor='white' >");
IsOddRowCount = true;
};
buffer.Append("<td align='left'>");
buffer.Append(CurrRow.TeamName);
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("Statistics");
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("Schedule");
buffer.Append("</td>");
buffer.Append("<td align='center'>");
buffer.Append("Players");
buffer.Append("</td>");
buffer.Append("</tr>");
}
buffer.Append("</Table>");
litTeamsByConference.Text = buffer.ToString();
}
}