Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net下拉列表无法获取文本值_C#_Asp.net_Drop Down Menu - Fatal编程技术网

C# asp.net下拉列表无法获取文本值

C# asp.net下拉列表无法获取文本值,c#,asp.net,drop-down-menu,C#,Asp.net,Drop Down Menu,在asp.net中,我有一个下拉列表,我用1到100的值填充它 <asp:Label ID="Label1" runat="server" Text=""></asp:Label> <asp:DropDownList ID="Product1dropdown" runat="server"></asp:DropDownList> <asp:Button ID="btnProduct1Addtocart" runat="server" Text

在asp.net中,我有一个下拉列表,我用1到100的值填充它

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:DropDownList ID="Product1dropdown" runat="server"></asp:DropDownList>
<asp:Button ID="btnProduct1Addtocart" runat="server" Text="Add to cart" onclick="btnAddtoChart1_Click" />

protected void btnAddtoChart1_Click(object sender, EventArgs e)
    {
        Label1.Text = Product1dropdown.SelectedItem.Text;
    }

无论我从下拉列表中选择什么,都无所谓,label1.text始终采用值“1”,这是下拉列表的默认值。感谢您的帮助。

是的,我也遇到了同样的问题。当我为dropdownlist使用文本字段(例如DataValueField=TextField)时,它将不会更新,并始终返回列表中的第一项作为其选定值,即使用户选择另一个至少在浏览器中更新的选项,这也很奇怪

当您的页面填充ddl时显示下拉列表填充codecheck。。。