如何解决具有相同值触发器的不同文本的DropDownList [英] how to solve DropDownList with Different Text with Same Value Trigger

查看:78
本文介绍了如何解决具有相同值触发器的不同文本的DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <asp:DropDownList runat="server" ID="ddlRole" AutoPostBack="true" OnSelectedIndexChanged="ddlRole_SelectedIndexChanged">

  <asp:ListItem Value="Master user" Text="Aby">
</asp:ListItem>
    <asp:ListItem Value="Master user" Text="Sanjay">
     </asp:ListItem>
<asp:ListItem Value="Master user" Text="Raymond">
      </asp:ListItem>
   <asp:ListItem Value="Master user" Text="Melvyn">
              </asp:ListItem>
    </asp:DropDownList>





每当ddlRole_SelectedIndexChanged fir它显示我选择的文字为Aby



请帮助



Whenever ddlRole_SelectedIndexChanged fir its shows me slected text as Aby

Please help

推荐答案

protected void ddlRole_SelectedIndexChanged(object sender, EventArgs e) 
{ 
string _selectedText = ddlRole.SelectedItem.Text;//to get the text of selected item
if (ddlRole.SelectedItem.Value != "Operational user") 
{ 
txtUser.ReadOnly = true; 
txtUser.Text = ddlRole.SelectedItem.Text; 
ScriptManager.RegisterClientScriptBlock(Page, GetType(), "Disable", "Disable()", true); 
} 
else 
{ 
txtUser.ReadOnly = false; 
txtUser.Text = ""; 
ScriptManager.RegisterClientScriptBlock(Page, GetType(), "Enable", "Enable()", true); 
} 
ddlRole.Items.FindByText(_selectedText).Selected = true;
} 


这篇关于如何解决具有相同值触发器的不同文本的DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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