ASP.default_aspx' 不包含'IssuesGrid_OnItemUpdated' 的定义并且没有扩展方法'IssuesGrid_OnItemUpdated' [英] ASP.default_aspx' does not contain a definition for 'IssuesGrid_OnItemUpdated' and no extension method 'IssuesGrid_OnItemUpdated'

查看:25
本文介绍了ASP.default_aspx' 不包含'IssuesGrid_OnItemUpdated' 的定义并且没有扩展方法'IssuesGrid_OnItemUpdated'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Telerik asp.net/ajax 控件创建了一个 gridview,当我在本地运行应用程序时,网格工作正常,但是当推送到我的服务器时,我的所有方法都出现相同的错误:

I created a gridview using Telerik asp.net/ajax controls and when I run the app locally the grid works fine but when pushed to my server I get the same error for all of my methods:

ASP.default_aspx' does not contain a definition for 'IssuesGrid_OnItemUpdated' and no extension method 'IssuesGrid_OnItemUpdated' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)

我已经尝试删除网格中的引用并再次创建它并让 VS 创建该方法,然后它会一直工作,直到我对所有抛出错误的方法执行此操作,然后重新开始.

I have tried deleting the reference in the grid and creating it again and letting VS create the method and then it'll work until I do that for all of the methods throwing the error and then it starts all over again.

这里是aspx页面:

   <telerik:RadGrid ID="Issues" runat="server" CellSpacing="0" DataSourceID="GridSource" GridLines="None" Skin="Metro"
                AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" OnItemDataBound="Issues_OnItemDataBound" 
                PageSize="30" EnableLinqExpressions="false" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
                AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                OnItemUpdated="Issues_OnItemUpdated" OnItemInserted="Issues_OnItemInserted" OnItemDeleted="Issues_OnItemDeleted"
                OnItemCommand="Issues_OnItemCommand"
                AutoGenerateColumns="False" ShowStatusBar="True" HorizontalAlign="Center" Height="900px">

这是我的 cs 文件中的方法:

And here are my methods in my cs file:

  protected void Issues_OnItemUpdated(object sender, GridUpdatedEventArgs e)
        {
            if (e.Exception != null)
            {
                e.KeepInEditMode = true;
                e.ExceptionHandled = true;
                DisplayMessage(true, "Defect " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"] + " cannot be updated. Reason: " + e.Exception.Message);
            }
            else
            {
                DisplayMessage(false, "Defect " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"] + " updated");
            }
        }

        protected void Issues_OnItemInserted(object source, GridInsertedEventArgs e)
        {
            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                e.KeepInInsertMode = true;
                DisplayMessage(true, "Defect cannot be inserted. Reason: " + e.Exception.Message);
            }
            else
            {
                DisplayMessage(false, "Defect inserted!");
            }
        }

        protected void Issues_OnItemDeleted(object source, GridDeletedEventArgs e)
        {
            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                DisplayMessage(true, "Defect " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"] + " cannot be deleted. Reason: " + e.Exception.Message);
            }
            else
            {
                DisplayMessage(false, "Defect " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"] + " deleted");
            }
        }


        protected void Issues_OnItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
            {
                var editColumn = (GridEditCommandColumn)Issues.MasterTableView.GetColumn("EditCommandColumn");
                editColumn.Visible = false;
            }
            else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted)
            {
                e.Canceled = true;
            }
            else
            {
                var editColumn = (GridEditCommandColumn)Issues.MasterTableView.GetColumn("EditCommandColumn");
                if (!editColumn.Visible)
                    editColumn.Visible = true;
            }
        }

奇怪的是,我有一个 ondatabound 方法,它很好,在任何这些问题开始之前就可以工作并继续工作.我尝试将对象发送者"更改为对象源",但还是不行.

What's weird is I have an ondatabound method that is just fine and worked before any of these problems started and continues to work. I tried changing the 'object sender' to 'object source' but still a no go.

这是 OnDataBound 事件:

Here is the OnDataBound event:

   protected void Issues_OnItemDataBound(object source, GridItemEventArgs e)
            {
                var gridDataItem = e.Item as GridDataItem;
                if (gridDataItem != null)
                {
                    var item = gridDataItem;

                    //Tooltips
                    if (!item.IsInEditMode)
                    {
                        var cell = item["Description"];
                        if (cell.Text.Length > 40)
                        {
                            var originaltext = cell.Text;
                            cell.Text = cell.Text.Remove(40) + "...";
                            cell.ToolTip = originaltext;
                        }
                    }
                }
}

对我做错的任何帮助都会很棒!

Any help on what I am doing wrong would be great!

推荐答案

您的代码隐藏(.cs 文件)在您部署时被编译成一个 dll.确保在发布时,这些 dll 文件也被复制.这也意味着您发布的项目不应包含任何 .cs.designer.cs 文件.

Your code-behind (the .cs file) gets compiled into a dll when you deploy. Ensure that when you publish, these dll files are being copied over as well. This also means your published project should not have any .cs or .designer.cs files.

这篇关于ASP.default_aspx' 不包含'IssuesGrid_OnItemUpdated' 的定义并且没有扩展方法'IssuesGrid_OnItemUpdated'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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