Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0I have solved my problem, now II have solved my problem, now I'd like to know why nobody else does it this way. A technical reason?
Previous
 
Next
New Post
2/12/2008 9:46 AM
 

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();


    }
}

 
New Post
2/12/2008 12:44 PM
 

There is plenty of room for different ideas. My concerns (and I could be wrong) however:

  • The ListView control is very extensible. It should do eaxcatly what you want. You will want to use the "events" exposed by the ListView and the LinqDataSource control to inject your business logic (see: http://www.adefwebserver.com/DotNetNukeHELP/LinqTutorial3/ for examples)
  • When you use controls like the ListView and the LinqDataSource control you can connect other controls to them. This will save a LOT of code. For example I have about as much code in the example link above yet the module has grouping, totaling, and paging.


Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0I have solved my problem, now II have solved my problem, now I'd like to know why nobody else does it this way. A technical reason?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out