Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem getting a datagrid to display information.

Status
Not open for further replies.

Sanjeet1

Programmer
Sep 4, 2003
26
US
I have a datagrid called: dgRevCatDisplay. When the page loads no data gets displayed.

I tried setting a breakpoint on the datagrid all the objects and methods that instantiate the datagrid seem to be ok.

However in debug mode when I type the object name in the immediate window I get an error message that says object not in scope.

I do have the datagrid instantiated in the class:

protected System.Web.UI.WebControls.DataGrid dgRevCatDisplay.

I put a this before the datagrid. Data does exist in the database.


Here is my code:

OnlineCaseCategoryController occc = new OnlineCaseCategoryController();
this.dgRevCatDisplay.DataSource = occc.List();
this.dgRevCatDisplay.DataBind();
 
hmm. what's an OnlineCaseCategoryController? what class is OnlineCaseCategoryController.List()?

as a first attempt try the following, before assigning the grid.DataSource().

Code:
foreach ( object o in occc.List() )
{
 Console.WriteLine(o.ToString()); 
}




mr s. <;)

 
here is muy code:

----------------------------------------------------
OnlineCaseCategoryController occc = new OnlineCaseCategoryController();
dgRevCatDisplay = new DataGrid();
dgRevCatDisplay.DataSource = occc.List();
dgRevCatDisplay.DataBind();
occc = null;
----------------------------------------------------

This is the object the populated the Datagrid:

---------------------------------------------
public class OnlineCaseCategoryController
{
public ArrayList List()
{
ArrayList infoList = null;
IDataReader idr = null;
try
{
idr = DataProvider.Instance().ListOnlineCaseCategory();
infoList = DotNetNuke.CBO.FillCollection(idr, typeof(OnlineCaseCategoryInfo));
}
finally
{
if (idr!=null)
{
idr.Close();
idr.Dispose();
idr = null;
}
}
return infoList;
}

----------------------------------------------------------------------
This is where the OnlineCaseCategoryInfo is declared. It's constructors are:
---------------------------------------------------------------------

infoList = DotNetNuke.CBO.FillCollection(idr, typeof(OnlineCaseCategoryInfo));




public class LookupInfoBase
{
private int _id;
string _description;

#region public properties
public int Id
{
get
{
return _id;
}
set
{
_id = value;
}
}

public class OnlineCaseCategoryInfo : LookupInfoBase
{
// local property declarations
int _categoryid;

#region Constructors
public OnlineCaseCategoryInfo()
{
}

public OnlineCaseCategoryInfo(int categoryid, string description)
{
this.Categoryid = categoryid;
this.Description = description;
}



 
why are you setting occc to null?

one more thing, you could try tidying the code with a using block:

Code:
using ( IDataReader idr = DataProvider.Instance().ListOnlineCaseCategory() )
{
 infoList = DotNetNuke.CBO.FillCollection(idr, typeof(OnlineCaseCategoryInfo)); 
}

this will call the dispose code automatically.

mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top