Simple datalist question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm converting an app written using the pure .net framework from command
line, to Visual studio 2003. Having a problem with the datalist that wasnt
there before:

e:\inetpub\wwwroot\WebApplication2\winelist.aspx.cs(38): The type or
namespace name 'MyList' could not be found (are you missing a using directive
or an assembly reference?)

MyList.DataSource = productlist.gettheitems(color, category, year, region,
appellation, country);
MyList.DataBind();

What am I missing?

TIA
D
 
I'm converting an app written using the pure .net framework from command
line, to Visual studio 2003. Having a problem with the datalist that
wasnt
there before:

e:\inetpub\wwwroot\WebApplication2\winelist.aspx.cs(38): The type or
namespace name 'MyList' could not be found (are you missing a using
directive
or an assembly reference?)

MyList.DataSource = productlist.gettheitems(color, category, year,
region,
appellation, country);
MyList.DataBind();

What am I missing?

TIA
D

I assume you probably copied your aspx code to the aspx file in Visual
Studio, and then moved your c# code from the new aspx to the code-behind?
If so, one thing you're missing is that when you drop a control on a form
(aspx), VS adds a field variable declaration to the code-behind for that
control. So if I dropped a Literal control on my form, in my code-behind
it adds:

class Page MyPage
{
....
//this line is added
protected System.Web.UI.WebControls.Literal ltlContent;
....
}

then you can access that control in your code-behind.

Remember the aspx file inherits from a code-behind file. So by doing
this, when the aspx file is loaded, the variable declaration is inherited
from the code-behind class, and .NET automatically associates the loaded
control in the page to it..

So put a line similar to this one in your code-behind class for each
server control, changing the type(s) to the corresponding control type...
 
Back
Top