如何从html中选择文本选择在asp.net代码隐藏?

问题描述:

I use html Select in apsx page and bind it to data in database as dropdown:

使用html选择apsx页面并将其绑定到数据库中的数据。 ddname =ddrunat =serverDataValueField =IDDataTextField =Name>

<SELECT id="dd" name="dd" runat="server" DataValueField="ID" DataTextField="Name">

然后在后面的代码中,我可以将选定的项目值(映射到ID)

Then in code behind, I can get the selected item value(which is mapped to ID) as:

myvalue = dd.value;

但是我想获取选定的文本(映射到Name),而不是代码中的值背后。如何做到这一点?

But I want to get the selected text(which is mapped to Name), not the value in code behind. How to do it?

试试这个dd.Items [dd.SelectedIndex] .Text

try this dd.Items[dd.SelectedIndex].Text