如何从html中选择文本选择在asp.net代码隐藏? [英] how to get selected text from html select in asp.net code-behind?

查看:97
本文介绍了如何从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

这篇关于如何从html中选择文本选择在asp.net代码隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆