C# 显示dropdownlist中选定项的标签中的值

C# 显示dropdownlist中选定项的标签中的值,c#,asp.net,C#,Asp.net,我有一个scrpt,当我从dropdownlist中选择一个项目时,我想在回发后在标签中显示值。当我从dropdownlist中选择一个项目时,例如“Apple”,它将在标签中显示苹果的价格。如果我在标签的下拉列表中选择“橙色”,它将显示橙色的价格。你知道怎么做吗?谢谢 这是代码 阿斯克氏接触肌 <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactDetails.ascx.cs" Inherits="U

我有一个scrpt,当我从dropdownlist中选择一个项目时,我想在回发后在标签中显示值。当我从dropdownlist中选择一个项目时,例如“Apple”,它将在标签中显示苹果的价格。如果我在标签的下拉列表中选择“橙色”,它将显示橙色的价格。你知道怎么做吗?谢谢

这是代码

阿斯克氏接触肌

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactDetails.ascx.cs"
    Inherits="UserControl_ContactDetails" EnableViewState="false"  %>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            width: 150px;
        }
        .auto-style3 {
            width: 294px;
        }
        .auto-style4 {
            width: 150px;
            text-align: right;
        }
    </style>
<table class="auto-style1">
    <tr>
        <td class="auto-style4">
            <asp:Label ID="Label7" runat="server" Text="Klienti:"></asp:Label>
        </td>

        <td class="auto-style3">
            <asp:DropDownList ID="DropDownListKlienti" runat="server">
            </asp:DropDownList>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style4">
            <asp:Label ID="Label1" runat="server" Text="Artikulli:"></asp:Label>
        </td>
        <td class="auto-style3">
            <asp:DropDownList ID="DropDownListArtikulli" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownListArtikulli_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style4">
            <asp:Label ID="Label2" runat="server" Text="Cmimi:"></asp:Label>
        </td>
        <td class="auto-style3">
            <asp:Label ID="LabelCmimi" runat="server"></asp:Label>
            <asp:Label ID="Label3" runat="server" Text="lek"></asp:Label>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style4">
            <asp:Label ID="Label4" runat="server" Text="Sasia:"></asp:Label>
        </td>
        <td class="auto-style3">
            <asp:TextBox ID="TextBoxSasia" runat="server" AutoPostBack="True" OnTextChanged="TextBoxSasia_TextChanged"></asp:TextBox>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style4">
            <asp:Label ID="Label5" runat="server" Text="Vlera:"></asp:Label>
        </td>
        <td class="auto-style3">
            <asp:Label ID="LabelVlera" runat="server"></asp:Label>
            <asp:Label ID="Label6" runat="server" Text="lek"></asp:Label>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">&nbsp;</td>
        <td class="auto-style3">&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">&nbsp;</td>
        <td class="auto-style3">&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">&nbsp;</td>
        <td class="auto-style3">&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">&nbsp;</td>
        <td class="auto-style3">&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>
删除AddItems();并将其添加到select_changed代码中

protected void DropDownListArtikulli_SelectedIndexChanged(object sender, EventArgs e)
{
    LabelCmimi.Text = DropDownListArtikulli.SelectedValue.ToString();
}

您的问题不清楚。您当前的代码有什么问题?它读回输入的值。您是否询问如何获取价格,因为您的问题不清楚。
protected void DropDownListArtikulli_SelectedIndexChanged(object sender, EventArgs e)
{
    LabelCmimi.Text = DropDownListArtikulli.SelectedValue.ToString();
}