我有一个下拉列表,必须展示从文件夹中的图像文件的名称,但是当我运行页面此错误累积:编译器错误信息:CS1061:
编译器错误信息:CS1061:' ASP.pagesnew_managementpages_manageproducts_aspx'不包含'ddImage_SelectedIndexChanged'的定义,并且没有找到接受类型为'ASP.pagesnew_managementpages_manageproducts_aspx'的第一个参数的扩展方法'ddImage_SelectedIndexChanged'(您是否缺少using指令或程序集引用?)
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ManageProducts.aspx.cs" Inherits="PagesNew_ManagementPages_ManageProducts" %>
那是错误的标签:
Image:</p>
Line 25: <p>
Line 26: <asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
Line 27: </asp:DropDownList>
Line 28: </p>
这是整个文件:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
Name:</p>
<p>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</p>
<p>
Type:</p>
<p>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [ProductTypes] ORDER BY [Name]"></asp:SqlDataSource>
</p>
<p>
Price:</p>
<p>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
</p>
<p>
Image:</p>
<p>
<asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
</asp:DropDownList>
</p>
<p>
Description:</p>
<p>
<asp:TextBox ID="txtDescription" runat="server" Height="72px" TextMode="MultiLine" Width="223px"></asp:TextBox>
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p>
<p>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</p>
</asp:Content>
我不明白什么是错?
你曾经定义过'ddImage_SelectedIndexChanged'吗? – 2015-01-09 21:29:53
错误消息不能更清晰......如果您在aspx文件中引用事件处理程序,则必须在代码隐藏中定义它。 – walther 2015-01-09 21:44:45
是的,我只是在代码隐藏中定义它,但我的图像名称是下拉列表中的项目没有显示在下拉列表中! – Shosho 2015-01-09 22:31:27