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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Data.DataTable denotes a class which is not valid in.. 1

Status
Not open for further replies.

matthewking

Programmer
Jul 15, 2002
75
ES
Hi,

I have the following code, and im getting this error on the line that creates a new DataTable object:-

System.Data.DataTable denotes a class which is not valid in the given context.

I've commented alot out trying to find the error, but it persists. Anyone have any ideas?

code:-

using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Spanish.Web.Components;

// <summary>
// Codebehind for VerbGrid.ascx
// </summary>

namespace Spanish.Web.Controls.Codebehind
{
public class VerbGrid : System.Web.UI.UserControl
{
public DataTable objDataTable;
public DataRow objDataRow;

public System.Web.UI.WebControls.DataGrid dg;

public void Page_Load(object sender, System.EventArgs e)
{

//createTable();
//populateTable();


//dg.DataSource = objDataTable;
//dg.DataBind();
}

public void createTable()
{
objDataTable = DataTable(&quot;Verbs&quot;);
//objDataTable.Columns.Add(&quot;VerbID&quot;, GetType(Integer));
//objDataTable.Columns.Add(&quot;Active&quot;, GetType(Integer));

//Session(&quot;Verbs&quot;) = objDataTable;
}

public void populateTable()
{
//objDataTable = Session(&quot;Verbs&quot;);

for(int i = 0; i <= 8; i++)
{
//objDataRow = objDataTable.NewRow();

verb myVerb = new verb();

//objDataRow(&quot;VerbID&quot;).Value = (int) myVerb.verbID;
//objDataRow(&quot;Active&quot;).Value = (int) 1;

//objDataTable.Rows.Add(objDataRow);
}
}
}
}
 
your line:
objDataTable = DataTable(&quot;Verbs&quot;);

should be:
objDataTable = new DataTable(&quot;Verbs&quot;);
 
heh,

I even typed that in at one stage, and decided it didnt look right and must be a vb.net only keyword. So I didnt bother saving and compiling =/

Thanks very much korach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top