Background: I’m working with a C# module in DNN vers. 4.93. The module is a Web Site Project. I am currently:
a.) Adding a Panel and DataGrid to the Edit User control.
I have performed the following steps:
1. Studied Mitch Sellers’ Course Gradebook module. The Course Gradebook is a C# module, which is a free download from his web site.
2. Created a new YourCompany_Assignments table (Based on the ICG_Assignments table in the Gradebook module).
3. Created the following stored procedures:
YourCompany_GetAssignments, YourCompany_GetGuestbook, YourCompany_GetGuestbooks, and YourCompany_UpdateGuestbook.
4. Copied the pnlDisplay and dgrAssignments from the Gradebook module and pasted them into the Edit User control.
5. Created the following new classes and copied the Gradebook code into them.
CourseGradebookController, DataProvider, MarkTest1Info and SqlDataProvider.
Question: Why will the DataGrid not appear on the test page?
Code Comments:
EditMarkTest1.ascx contains the DataGrid control.
----------------------------------------------------------------------------------------------------------------------------------------------------
File: EditMarkTest1.ascx
<%@ Control language=”C#” Inherits=”YourCompany.Modules.MarkTest1.EditMarkTest1” CodeFile=”EditMarkTest1.ascx.cs” AutoEventWireup=”true”%>
<%@ Register TagPrefix=”dnn” TagName=”Label” Src=”~/controls/LabelControl.ascx” %>
<%@ Register TagPrefix=”dnn” TagName=”TextEditor” Src=”~/controls/TextEditor.ascx”%>
<%@ Register TagPrefix=”dnn” TagName=”Audit” Src=”~/controls/ModuleAuditControl.ascx” %>
--------------------------------------------------------------------------------------------------------------------------------------------------------------
File: EditMarkTest1.ascx.cs
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Globalization;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
namespace YourCompany.Modules.MarkTest1
{
partial class EditMarkTest1 : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
//display panel
pnlDisplay.Visible = true;
//Get the course settings - due to module restrictions we know a course is associated
//CourseGradebookController oController = new CourseGradebookController();
}
//Line 69
///
/// Retreives and binds the list of assignments
/// private void BindGrid()
{
CourseGradebookController oController = new CourseGradebookController();
//Get entries
List
oAssignments = oController.GetAssignments(PortalId, int.Parse(Settings[“ICG_CourseGradebook_AssociatedCourse”].ToString()));
//Bind
dgrAssignments.DataSource = oAssignments;
dgrAssignments.DataBind();
/*
private const decimal MinBasePrice = 0.0m;
private const decimal MaxBasePrice = 1000.00m;
private const decimal MinPerUnitPrice = 0.0m;
private const decimal MaxPerUnitPrice = 1000.00m;
private const int MinTaxRate = 0;
private const int MaxTaxRate = 1;
private const int MaxShippingMethodNameLength = 50;
private const int MaxNumTextboxLengthLength = 9;
private const decimal MinRetailPrice = 0.0m;
private const decimal MaxRetailPrice = 1000000;
private const decimal MinPrice = 0.0m;
private const decimal MaxPrice = 1000000;
private const int MinShippingUnits = 0;
private const int MaxShippingUnits = 10000;
private const string NewItemId = “New”;
protected enum AdminState
{
MainMenu,
ProductList,
ProductEdit,
TaxEdit,
TaxList,
ShippingEdit,
ShippingList,
SettingsEdit
}
*/
}
// #region Button Response Events
///
/// Responds to clicks inside the data grid
///
///
///
protected void dgrAssignments_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
/*
//Act based on command
switch (e.CommandName)
{
case “Edit”:
//Grab values
lblAssignmentId.Text = e.Item.Cells[1].Text;
txtAssignmentName.Text = e.Item.Cells[3].Text;
txtPointsPossible.Text = e.Item.Cells[4].Text;
txtDueDate.Text = DateTime.Parse(e.Item.Cells[5].Text).ToShortDateString();
//Hide grid panel
pnlDisplay.Visible = false;
//Show Edit
pnlAddEdit.Visible = true;
break;
case “Delete”:
//Delete record
CourseGradebookController oController = new CourseGradebookController();
oController.DeleteAssignment(int.Parse(e.Item.Cells[1].Text), PortalId);
//Rebind grid
BindGrid();
break;
*/
}
///
/// Starts the user on an addition
///
///
///
protected void btnAddAssignment_Click(object sender, EventArgs e)
{
/* //Assignment id = -1
lblAssignmentId.Text = “-1”;
//Set display
pnlAddEdit.Visible = true;
pnlDisplay.Visible = false;
* */
}
}//end class
}//end namespace
//}
--------------------------------------------------------------------------------------------------------------------------------------
File: CourseGradebookController.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search;
//namespace ICG.CourseGradebook.Components
namespace YourCompany.Modules.MarkTest1
{
public class CourseGradebookController
{
#region Public Assignment Methods
/*
///
/// Retreives the information for one specific assignment
///
/// The id of the portal
/// The name of the course
/// The id of the assignment
/// A populated object
public CourseAssignmentInfo GetAssignment(int portalId, int courseId, int assignmentId)
{
return CBO.FillObject(DataProvider.Instance().GetAssignment(portalId, courseId, assignmentId));
}
*/
///
/// Retreives a listing of all assignments for the specified course
///
/// The id of the portal
/// The name of the course
///
public List GetAssignments(int portalId, int courseId)
{
return CBO.FillCollection(DataProvider.Instance().GetAssignments(portalId, courseId));
}
///
/// Adds a new assignment to the system
///
/// The assignment information
/*
public void AddAssignment(CourseAssignmentInfo info)
{
DataProvider.Instance().AddAssignment(info.PortalId, info.CourseId, info.AssignmentName, info.PointsPossible, info.DueDate);
}
*/
/*
///
/// Updates an existing assignment within the system
///
/// The assignment information
public void UpdateAssignment(CourseAssignmentInfo info)
{
DataProvider.Instance().UpdateAssignment(info.AssignmentId, info.PortalId, info.CourseId, info.AssignmentName, info.PointsPossible, info.DueDate);
}
*/
/*
///
/// Removes an assignment
///
///
///
public void DeleteAssignment(int assignmentId, int portalId)
{
DataProvider.Instance().DeleteAssignment(assignmentId, portalId);
}
*/
#endregion
/*
#region Public User Assignment Methods
public List GetUserAssignments(int portalId, int courseId, int userId)
{
return CBO.FillCollection(DataProvider.Instance().GetUserAssignments(portalId, courseId, userId));
}
public UserAssignmentInfo GetUserAssignment(int userAssignmentId)
{
return CBO.FillObject(DataProvider.Instance().GetUserAssignment(userAssignmentId));
}
public void AddUserAssignment(UserAssignmentInfo info)
{
DataProvider.Instance().AddUserAssignment(info.AssignmentId, info.UserId, info.ScoreReceived, info.DateEntered, info.Comment);
}
public void UpdateUserAssignment(UserAssignmentInfo info)
{
DataProvider.Instance().UpdateUserAssignment(info.UserAssignmentId, info.AssignmentId, info.UserId, info.ScoreReceived, info.DateEntered, info.Comment);
}
public void DeleteUserAssignment(int userAssignmentId)
{
DataProvider.Instance().DeleteUserAssignment(userAssignmentId);
}
#endregion
*/
/*
#region Public User Gradebook Methods
///
/// Retreives the users gradebook
///
/// The id of the portal
/// The course name
/// The id of the user
///
public List GetUserGradebook(int portalId, int courseId, int userId)
{
return CBO.FillCollection(DataProvider.Instance().GetUserGradebook(portalId, courseId, userId));
}
///
/// Retreives the users current grade in the course
///
/// The id of the portal
/// The id of the course
/// The id of the user
///
///
public UserCurrentGradeInfo GetUserCurrentGrade(int portalId, int courseId, int userId)
{
return CBO.FillObject(DataProvider.Instance().GetUserCurrentGrade(portalId, courseId, userId));
}
#endregion
#region Public CourseSetting Methods
///
/// Retreives the settings for a specific course
///
/// The id of the course
/// The id of the portal
///
public CourseSettingInfo GetCourseSetting(int courseId, int portalId)
{
return CBO.FillObject(DataProvider.Instance().GetCourseSetting(courseId, portalId));
}
///
/// Retrieves all course settings for a portal
///
/// The id of the portal
///
public List GetCourseSettings(int portalId)
{
return CBO.FillCollection(DataProvider.Instance().GetCourseSettings(portalId));
}
///
/// Adds a new course setting record to the database
///
/// The populated info
public void AddCourseSetting(CourseSettingInfo oInfo)
{
DataProvider.Instance().AddCourseSetting(oInfo.PortalId, oInfo.CourseAcronym, oInfo.CourseDisplayName, oInfo.StudentViewEnabled, oInfo.StudentRole, oInfo.ShowStudentsGrade, oInfo.ACutoff, oInfo.BCutoff, oInfo.CCutoff, oInfo.DCutoff);
}
///
/// Updates an existing course setting
///
/// The populated info
public void UpdateCourseSetting(CourseSettingInfo oInfo)
{
DataProvider.Instance().UpdateCourseSetting(oInfo.CourseId, oInfo.PortalId, oInfo.CourseAcronym, oInfo.CourseDisplayName, oInfo.StudentViewEnabled, oInfo.StudentRole, oInfo.ShowStudentsGrade, oInfo.ACutoff, oInfo.BCutoff, oInfo.CCutoff, oInfo.DCutoff);
}
///
/// Removes an existing course setting from the db
///
/// The id of the course
/// The id of the portal
public void DeleteCourseSetting(int courseId, int portalId)
{
DataProvider.Instance().DeleteCourseSetting(courseId, portalId);
}
#endregion
*/
/*
#region Public User Email OptOut Methods
public UserEmailOptOut GetUserEmailOptOut(int portalId, int userId)
{
return CBO.FillObject(DataProvider.Instance().GetUserEmailOptOut(portalId, userId));
}
public void SetUserEmailOptOut(UserEmailOptOut oInfo)
{
DataProvider.Instance().SetUserEmailOptOut(oInfo.PortalId, oInfo.UserId, oInfo.OptOut);
}
#endregion
*/
}
}