返回下拉列表所选项目的文本 [英] return text of dropdownlist selected item

查看:92
本文介绍了返回下拉列表所选项目的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在选择下拉列表中的一项时返回所选项目的文本,因为当我单击下拉列表中的一项并单击button1时,请给我1或第一项下拉列表

I want when select a item of dropdown list, return text of selected item because when I do click on the a item of dropdown list and click on button1 give me 1 or first item of dropdownlist

button1_click()
{
    dropdownlist1.SelectedValue.ToString();
}


我如何通过单击button1返回所选项目的文本?


how i do return text of selected item with click on button1?

推荐答案

看起来像您忘记了将下拉绑定代码放在Page.IsPostback属性中.如果不执行此操作,则在每次发回邮件时,下拉列表将重新绑定并重置为第一个值.

做:
Looks like you forgot to put your dropdown bind code in Page.IsPostback property. If you do not do this then on every post back, dropdown will rebind and get reset to first value.

Do:
if(!IsPostback)
{
   // dropdown bind code
}


dropdownlist1.SelectedText.ToString()



再见!!!



Bye!!!


这篇关于返回下拉列表所选项目的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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