使用下拉列表中的选定值 [英] Work with selected value in dropdownlist

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

问题描述

尝试根据选择的值测试下拉列表.else部分确实有效,因为执行了内部代码,并且我102%确信满足条件,所以我在下拉列表中使用了该名称. ,我需要帮助.

Been trying to test a drop down list according to selected value.The else part does work since the code inside is executed, and I am 102% sure that the condition is met, I have that name in my dropdown.Its confusing,i need help.

<asp:DropDownList ID="ddlStaff"  runat="server" AutoPostBack="true"

                 BackColor="#CCCCCC" ForeColor="Black"  Height="18px" Width="167px"

                    onselectedindexchanged="ddlStaff_SelectedIndexChanged">
             </asp:DropDownList>



以下是下拉菜单中的代码



Below is the code behind the drop down

if (ddlStaff.SelectedIndex.ToString() == "Anele ngqandu")
       {
           MessageBox.Show("ys");
       }
       else
       {
           radDoctors.Checked = true;
       }

推荐答案

您正在使用SelectedIndex,它应该是SelectedItem.Text或SelectedItem.Value(以适用者为准).
You are using SelectedIndex, it should be either SelectedItem.Text or SelectedItem.Value (whichever is applicable).


你好朋友
<pre lang="midl">Lable1.Text = DropDownList1.SelectedValue.ToString();<br />
if( label1.text == "selected value of DDBL")<br />
{<br />
       respose.write("done");<br />
}        <br />
<br />
</pre><br />




尝试使用此代码以获取帮助.




try this code its help u.


您可以使用DropDownList1.SelectedItem.Text或DropDownList1.SelectedValue例如

you may use DropDownList1.SelectedItem.Text or DropDownList1.SelectedValue for example

if (ddlStaff.SelectedItem.Text == "Anele ngqandu")
       {
           MessageBox.Show("ys");
       }
       else
       {
           radDoctors.Checked = true;
       }


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

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