我使用Telerik asp.net/ajax控件创建了一个gridview,当我在本地运行应用程序时,网格工作正常,但当推送到我的服务器时,我的所有方法都出现了同样的错误:
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创建该方法然后它将工作,直到我为所有抛出错误的方法执行该操作然后它重新开始。
这是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文件中的方法:
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方法,在任何这些问题开始并继续工作之前就可以了。我尝试将“对象发送者”更改为“对象来源”,但仍然不行。
这是OnDataBound事件:
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;
}
}
}
}
任何关于我做错事的帮助都会很棒!
答案 0 :(得分:0)
您的代码隐藏(.cs
文件)在部署时会被编译为dll
。确保在发布时,这些dll
文件也会被复制。这也意味着您发布的项目不应包含任何.cs
或.designer.cs
个文件。