我有一個下拉列表,必須展示從文件夾中的圖像文件的名稱,但是當我運行頁面此錯誤累積:編譯器錯誤信息: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