在我的ASP.NET项目没有Default.aspx.designer.cs文件 [英] No Default.aspx.designer.cs files in my ASP.NET project

查看:2292
本文介绍了在我的ASP.NET项目没有Default.aspx.designer.cs文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的网站没有任何designer.cs文件。 (是的,它不是一个Web应用程序)

该网站是完整的,但现在我加了2 Clases到我的网站和所有的好,但是当我想利用我的GridView的它告诉我:

这是因为我包我的code具有相同的命名空间在我的课像这样....

 命名空间samrasWebPortalSQL
  {
     公共部分类的GridView:System.Web.UI.Page
   {
    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        Functions.RemoveCaching(本);
        LoadGrid();    }    私人无效LoadGrid()
    {
        数据集的数据集= SQLHelper.GetDataSet(选择公司*);
        Functions.BindGridView(GridView1,数据集);
    }   }
}

我知道我需要以下code我了.Designer.cs文件,但因为我不有一个斜面我把它放在任何地方厄尔?

 保护全球:: System.Web.UI.WebControls.GridView GridView1;


解决方案

在您的网站,您可以添加一个新的ASPX页面(Web窗体)。而在Web表单您可以拖动一个GridView控件到该页面。一旦你给了它一个ID是这样的:

 < D​​IV>
< ASP:GridView控件ID =GRID1=服务器>< / ASP:GridView的>
< / DIV>

然后,您可以去后面的code和做这样的事情:

 保护无效的Page_Load(对象发件人,EventArgs的发送)
{
    Grid1.DataSource = ..;
}

如果你把你的code后面在不同的类名或命名空间,那么你需要告诉你的web表单在哪里可以找到它。您可以通过chaning page指令的财产继承这样做:

 <%@页面语言=C#AutoEventWireup =真codeFILE =Default2.aspx.cs继承=samrasWebPortalSQL.GridView%GT;

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:

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;

解决方案

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" %>

这篇关于在我的ASP.NET项目没有Default.aspx.designer.cs文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆