如何突出显示下拉列表中的所选项目 [英] How to highlight selected item in dropdown list

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

问题描述

你好朋友,
我已将组添加到下拉列表中,但工作正常,但是当我单击gridview中的edit选项时,该组的当前值必须保留在下拉列表中,因为该当前值必须在下拉列表中突出显示. br/> 预先感谢您

hello friends,
I have added groups to an dropdown list it is working fine but when I click on edit option which is in gridview then the present value of the group must be retain in the dropdown list that is the persent value must be highlighted in dropdown list.
Thanking you in advance

推荐答案

您是否要说单击网格中的编辑"按钮后下拉列表中的选定值已更改?

如果是这种情况,那么您必须重新分配下拉菜单的选定值,以在回发后显示选定的值.

如果没有,请提供您要实现的目标示例代码.
Are you trying to say that Drop down selected value is changed after clicking edit button in grid ?

if this is the case then you have to reassign the selected value of dropdown to present selected value after postback.

if not then please provide sample code of what are you trying to achieve..


找到ListItem并突出显示BackColor或选择该项
Find the ListItem and highlight the BackColor or select the item
protected void button1_Click(object sender, EventArgs e){    
//Find element by Text or value    
ListItem lstItem = DropDownList1.Items.FindByText(TextBox1.Text);    
if (lstItem != null)    
  {        
   lstItem.Attributes.Add("style", "background-color:Red;");        
   //You can also select the item        
   //lstItem.Selected = true;    
  }
}


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

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