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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDataGrid Control Not VisibleDataGrid Control Not Visible
Previous
 
Next
New Post
3/8/2010 12:26 PM
 

 


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
*/
}
}

 
New Post
3/8/2010 3:57 PM
 
It could be the formatting here, but I don't see a call to the BindGrid() method in the page load.

-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
3/8/2010 5:58 PM
 
Hi Mitchel, Thank you for your prompt response to my question. I added the following code to the Page_Load method and the result is a critical error. Here’s the contents of the Page_Load method: //Get the course settings - due to module restrictions we know a course is associated CourseGradebookController oController = new CourseGradebookController(); //CourseSettingInfo oSettings = oController.GetCourseSetting(int.Parse(Settings[“ICG_CourseGradebook_AssociatedCourse”].ToString()), PortalId); //Get the grid BindGrid(); //display panel pnlDisplay.Visible = true;
 
New Post
3/9/2010 6:22 PM
 
The Event Viewer shows an entry (for the critical error) for the following line in EditMarkTest1.ascx.cs:
//Get entries
List oAssignments = oController.GetAssignments(PortalId, int.Parse(Settings["ICG_CourseGradebook_AssociatedCourse"].ToString()));

I don’t understand how to deal with the following:
Settings["ICG_CourseGradebook_AssociatedCourse"]

Here are the contents of the Event Viewer entry:

AssemblyVersion: 04.09.03
PortalID: 0
PortalName: My Website
UserID: 1
UserName: dnnhost
ActiveTabID: 59
ActiveTabName: MarkTest1
RawURL: /dnn3/MarkTest1/tabid/59/Default.aspx
AbsoluteURL: /dnn3/Default.aspx
AbsoluteURLReferrer:
UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6.4; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 24760cd6-c8a2-467e-986d-78e43501db1f
InnerException: Object reference not set to an instance of an object.
FileName: c:\junk\dnn3\DesktopModules\MarkTest1\EditMarkTest1.ascx.cs
FileLineNumber: 82
FileColumnNumber: 13
Method: YourCompany.Modules.MarkTest1.EditMarkTest1.BindGrid
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at YourCompany.Modules.MarkTest1.EditMarkTest1.BindGrid() in c:\junk\dnn3\DesktopModules\MarkTest1\EditMarkTest1.ascx.cs:line 82 at YourCompany.Modules.MarkTest1.EditMarkTest1.Page_Load(Object sender, EventArgs e) in
c:\junk\dnn3\DesktopModules\MarkTest1\EditMarkTest1.ascx.cs:line 45 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
Source:
Server Name: MARK
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesDataGrid Control Not VisibleDataGrid Control Not Visible


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