Re: Simple datalist question
- From: "Craig Deelsnyder" <cdeelsny@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Apr 2005 13:10:57 -0500
On Tue, 19 Apr 2005 12:51:02 -0500, dinesh <dinesh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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...
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET .
- References:
- Simple datalist question
- From: dinesh
- Simple datalist question
- Prev by Date: RE: Simple datalist question
- Next by Date: Re: Help with Web Custom Control
- Previous by thread: RE: Simple datalist question
- Next by thread: Dropdownlist setting index to 0
- Index(es):
Relevant Pages
|