views:

34

answers:

1

My current Web Site does not have any designer.cs files. (Yes it is not a Web Application)

The site is complete but now I added 2 Clases to my site and all good but when I want to make use of my GridView it tells me this:

alt text

This is because I wrapped my code with the same namespace as in my classes like so....

  namespace samrasWebPortalSQL
  {
     public partial class GridView : System.Web.UI.Page
   {
    protected void Page_Load(object sender, EventArgs e)
    {
        Functions.RemoveCaching(this);
        LoadGrid();

    }

    private void LoadGrid()
    {
        DataSet dataSet = SQLHelper.GetDataSet("select * from company");
        Functions.BindGridView(GridView1, dataSet);
    }

}

}

I know I need the following code in my .designer.cs file but since I dont have one cant I place it anywhere ells?

protected global::System.Web.UI.WebControls.GridView GridView1;

Thanks in advanced!

+1  A: 

In your "web site", you can add a new ASPX page (Web Form). And in that web form you can drag a GridView onto that page. Once you've given it an ID like this:

<div>
<asp:gridview ID="Grid1" runat="server"></asp:gridview>
</div>

You can then go to the code behind and do something like this:

protected void Page_Load(object sender, EventArgs e)
{
    Grid1.DataSource =..;
}

If you put your code behind in a different class name or namespace, then you need to tell your web form where to find it. You do this by chaning the Inherits property of the page directive like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="samrasWebPortalSQL.GridView" %>
Matt Roberts
The problem is then how can/do I reference a class in a normal WEB SITE?
Etienne
Got you - you need to tell your web form what file to use as the code behind. And since you've changed the namespace, you need to change the Inherits property of your page directive: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="samrasWebPortalSQL.GridView" %>
Matt Roberts
Cool thanks! Please set this as the answer and I will mark it as correct!
Etienne
Glad to help :) Updated my answer
Matt Roberts