所以这个错误来自于尝试解决我在 Telerik RadGrid 中遇到的另一个问题,但我觉得这个问题只是因为我在拿起别人的代码之前从未真正编写过完整的 C# 程序。我意识到大约有 100 个人也提出了同样的问题,但这些解决方案都没有帮助。我已经部署了我的 dll,手动重新生成了设计器文件,重命名了处理的事件,检查了它没有在任何地方重复,我不知道还能做什么。
我的 ascx 文件的顶部:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="blahblah.ascx.cs"
Inherits="blah.blahh.blahblah" %>
<%@ Register Assembly="Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
我试图处理的事件是用于 Telerik RadGrid 排序和分页的 OnNeedDataSource。
因此,这是我的 ascx 文件中的几段代码:
<telerik:RadGrid HeaderStyle-BackColor="#1C5E55" AllowAutomaticInserts="false"
AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" OnDeleteCommand="rgCanonicalRelationships_DeleteCommand"
CommandItemStyle-CssClass="ms-stylelabel" AutoGenerateColumns="false" runat="server" OnNeedDataSource="rgCanonicalRelationships_NeedDataSource"
Skin="Web20" CommandItemStyle-Font-Names="tahoma" CommandItemStyle-Font-Size="XX-Small" AllowSorting="true">
<MasterTableView AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false"
BorderStyle="Solid" BorderWidth="1px" HeaderStyle-BackColor="#1C5E55" ItemStyle-BackColor="LightGray"
CommandItemDisplay="None">
</MasterTableView>
</telerik:RadGrid>
正确链接的代码隐藏
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using System.Collections;
using System.Web.Services;
using Telerik.WebControls;
namespace blah.blahh
{
public partial class blahblah :
{
这是与我定义的函数
protected void rgCanonicalRelationships_NeedDataSource(object sender, EventArgs e)
{
BuildCanonicalRelationshipsTable();
}
:我试图避免发布我的所有代码,因此如果您需要查看更多代码,请告诉我。我已经为此苦苦挣扎了一段时间,我觉得有些事情我应该做,但还没有做
使用此 OnNeedDataSource 事件是解决网格在排序时消失并且仅在重新绑定网格时重新出现的问题的建议方法
编辑:
抱歉忘记了错误消息,因为我经常看到它:
描述:编译服务此请求所需的资源期间发生错误。请查看以下具体错误详细信息并适当修改您的源代码。
编译器错误消息:CS1061:“ASP.blah_blahh_blahblah_ascx”不包含“rgCanonicalRelationships_NeedDataSource”的定义,并且找不到接受“ASP.blah_blahh_blahblah_ascx”类型的第一个参数的扩展方法“rgCanonicalRelationships_NeedDataSource”(您是否缺少使用指令或程序集参考?)
来源错误:
第 113 行:
第 114 行:
第 115 行:
源文件:c:\Inetpub\wwwroot\wss\VirtualDirectories\3718\blah\blahh\blahblah.ascx 行:115
So this error is coming from an attempt to solve another issue I am having with Telerik RadGrid but I feel like this problem is just due to the fact that I never actually written a full C# program before an I am picking up someone else's code. I realize that about 100 other people have posted this same question but none of those solutions helped. I have deployed my dlls, manually regenerated the designer file, renamed the event handled, checked its not repeated anywhere and I don't know what else to do.
The top of my ascx file:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="blahblah.ascx.cs"
Inherits="blah.blahh.blahblah" %>
<%@ Register Assembly="Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
The event I'm trying to handle is OnNeedDataSource used for the Telerik RadGrid sorting and paging.
So heres a couple pieces of my code the ascx file:
<telerik:RadGrid HeaderStyle-BackColor="#1C5E55" AllowAutomaticInserts="false"
AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" OnDeleteCommand="rgCanonicalRelationships_DeleteCommand"
CommandItemStyle-CssClass="ms-stylelabel" AutoGenerateColumns="false" runat="server" OnNeedDataSource="rgCanonicalRelationships_NeedDataSource"
Skin="Web20" CommandItemStyle-Font-Names="tahoma" CommandItemStyle-Font-Size="XX-Small" AllowSorting="true">
<MasterTableView AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false"
BorderStyle="Solid" BorderWidth="1px" HeaderStyle-BackColor="#1C5E55" ItemStyle-BackColor="LightGray"
CommandItemDisplay="None">
</MasterTableView>
</telerik:RadGrid>
and here is the code-behind properly linked
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using System.Collections;
using System.Web.Services;
using Telerik.WebControls;
namespace blah.blahh
{
public partial class blahblah :
{
with my function defined:
protected void rgCanonicalRelationships_NeedDataSource(object sender, EventArgs e)
{
BuildCanonicalRelationshipsTable();
}
I'm trying to avoid posting all of my code so if you need to see more let me know. I've been struggling with this for a while and I feel like theres something I'm supposed to do and just haven't
Using this OnNeedDataSource event was the suggested way to fix the problem of having my grid disappear on sorting and only reappear upon rebinding the grid
Edit:
Sorry forgot about the Error message since I've been seeing it so much:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'ASP.blah_blahh_blahblah_ascx' does not contain a definition for 'rgCanonicalRelationships_NeedDataSource' and no extension method 'rgCanonicalRelationships_NeedDataSource' accepting a first argument of type 'ASP.blah_blahh_blahblah_ascx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 113: <tr class="ms-stylelabel">
Line 114: <td colspan="2">
Line 115: <telerik:RadGrid HeaderStyle-BackColor="#1C5E55" AllowAutomaticInserts="false"
Line 116: AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" OnDeleteCommand="rgCanonicalRelationships_DeleteCommand"
Line 117: CommandItemStyle-CssClass="ms-stylelabel" AutoGenerateColumns="false" runat="server" OnNeedDataSource="rgCanonicalRelationships_NeedDataSource"
Source File: c:\Inetpub\wwwroot\wss\VirtualDirectories\3718\blah\blahh\blahblah.ascx Line: 115
发布评论
评论(2)
清除您的临时文件ASP.NET 文件
链接帖子中推荐的方法对我来说似乎有点奇怪。我更喜欢下面的批处理脚本。请注意,此脚本必须在 Windows Vista / 7 下以管理员身份运行。
更新 #1
如果清除临时 ASP.NET 文件无法解决问题,我建议创建一个新的 UserControl 并复制旧 UserControl 的标记和代码隐藏(不包括标记中的
CodeBehind
和Inherits
声明以及代码隐藏文件的类名)。如果标记文件/代码隐藏文件/代码隐藏类的名称不同步,则可能会出现 CS1061 错误,而创建新的 UserControl 是确保情况并非如此的最简单方法。Clear your Temporary ASP.NET Files
The method recommended in the linked post seems a bit wonky to me. I prefer the following batch script. Note that this script must be run as an Administrator under Windows Vista / 7.
Update #1
If clearing your Temporary ASP.NET Files doesn't solve the problem, I would suggest creating a new UserControl and copying the markup and the code-behind from the old UserControl (excluding the
CodeBehind
andInherits
declarations in the markup and the class name of the code-behind file). The CS1061 error can occur if the name of the markup file / code-behind file / code-behind class are not synchronized, and creating a new UserControl is the simplest way to ensure that is not the case.正如我所预料的,由于我缺乏使用 ASP 以及我正在使用的软件和环境的经验,我只是编译错误,因此一切都变得一团糟,尽管有些东西正在工作,所以看起来没问题。
As I expected due to my inexperience working with ASP and the software and environment I'm working in I was just compiling wrong and hence everything was getting messed up even though some stuff was working so it seemed ok.