C# 缺少using指令或程序集引用。VisualStudioWebDeveloper 2010
所以我很难弄清楚我到底做错了什么。 我会给你一个我一直在做的基本概述 我正在创建一个详细信息,其中一行数据是布尔值,我们最初使用的是CheckBoxField,但现在我们要删除它并使用布尔值(True或False更改为Yes或No)。 因此,我删除了CheckBowField,将数据字段设置为“中断”,然后使用代码C# 缺少using指令或程序集引用。VisualStudioWebDeveloper 2010,c#,visual-studio-2010,visual-web-developer-2010,C#,Visual Studio 2010,Visual Web Developer 2010,所以我很难弄清楚我到底做错了什么。 我会给你一个我一直在做的基本概述 我正在创建一个详细信息,其中一行数据是布尔值,我们最初使用的是CheckBoxField,但现在我们要删除它并使用布尔值(True或False更改为Yes或No)。 因此,我删除了CheckBowField,将数据字段设置为“中断”,然后使用代码 using System; using System.Data; using System.Configuration; using System.C
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CustomFormatting_DetailsViewTemplateField : System.Web.UI.Page
{
protected string DisplayDiscontinuedAsYESorNO(bool discontinued)
{
if (discontinued)
return "YES";
else
return "NO";
}
}
进入我的.aspx.cs页面,我发现了这个错误
说明:编译服务此请求所需的资源时出错。请查看以下特定错误详细信息,并适当修改源代码
编译器错误消息:CS1061:“ASP.customformatting\u detailsviewtemplatefield\u aspx”不包含“DetailsView1\u PageIndexChanging”的定义,并且没有扩展方法“DetailsView1\u PageIndexChanging”接受类型为“ASP”的第一个参数。找不到customformatting\u detailsviewtemplatefield\u aspx(是否缺少using指令或程序集引用?)
源错误:
Line 3:
Line 4: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
Line 5: <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
Line 6: DataKeyNames="ProductID" DataSourceID="ObjectDataSource1"
Line 7: onpageindexchanging="DetailsView1_PageIndexChanging">
第3行:
第4行:
第5行:
最后,这里是我的DetailsView的代码
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="ProductID" DataSourceID="ObjectDataSource1"
onpageindexchanging="DetailsView1_PageIndexChanging">
<Fields>
<asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />
<asp:BoundField DataField="SupplierName" HeaderText="Supplier" ReadOnly="True" SortExpression="SupplierName" />
<asp:BoundField DataField="QuantityPerUnit" HeaderText="Qty/Unit" SortExpression="QuantityPerUnit" />
<asp:TemplateField HeaderText="Price and Inventory">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("UnitPrice", "{0:C}") %>'></asp:Label>
<br />
<strong>(In Stock / On Order: </strong>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("UnitsInStock") %>'></asp:Label>
<strong>/</strong>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("UnitsOnOrder") %>'>
</asp:Label><strong>)</strong>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UnitPrice" HeaderText="Price" SortExpression="UnitPrice"
DataFormatString="{0:c}" Visible="False" />
<asp:BoundField DataField="UnitsIStock" HeaderText="Units In Stock" SortExpression="UnitsInStock"
Visible="False" />
<asp:BoundField DataField="UnitsOnOrder" HeaderText="Units On Order" SortExpression="UnitsOnOrder"
Visible="False" />
<asp:TemplateField HeaderText="Discontinued">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Discontinued") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Discontinued") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Discontinued") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
(库存/订单:
/
)
很抱歉,如果我发布了太多的代码,我只是不太确定您可能需要什么来帮助我解决我的问题。我对整个Visual Basic内容还是新手。
非常感谢您的建议!您在您的aspx页面和标记中放置了一个
DetailsView
控件,您声明将为onpageindexchanging
事件提供一个eventhandler,但您的代码中没有提供实现
来自MSDN的示例
protected void CustomerDetailView_PageIndexChanging(
object sender, DetailsViewPageEventArgs e)
{
// Cancel the paging operation if the user tries to
// navigate to another record while in edit mode.
if (CustomerDetailView.CurrentMode == DetailsViewMode.Edit)
{
e.Cancel = true;
// Display an error message.
ErrorMessageLabel.Text =
"You cannot navigate to another record while in edit mode.";
}
}
看