无误选择列表项的值或文本 listbox,dropdownlist,radiobuttonlist 函数
2008-12-02 14:37
323 查看
//选中选项
public void SelectListIndex(ref ListControl wc, string textOrValue, bool isText)
{
string tempType = wc.GetType().ToString();
tempType = tempType.Replace("System.Web.UI.WebControls.", "").ToLower();
if (tempType == "listbox")
{
if (isText)
((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByText(textOrValue));
else
((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByValue(textOrValue));
}
else if (tempType == "dropdownlist")
{
if (isText)
((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByText(textOrValue));
else
((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByValue(textOrValue));
}
else if (tempType == "radiobuttonlist")
{
if (isText)
((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByText(textOrValue));
else
((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByValue(textOrValue));
}
}
谢谢大家的支持,帮我点下需要的广告谢谢我会更加努力整理我的百科服务大家
public void SelectListIndex(ref ListControl wc, string textOrValue, bool isText)
{
string tempType = wc.GetType().ToString();
tempType = tempType.Replace("System.Web.UI.WebControls.", "").ToLower();
if (tempType == "listbox")
{
if (isText)
((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByText(textOrValue));
else
((ListBox)wc).SelectedIndex = ((ListBox)wc).Items.IndexOf(((ListBox)wc).Items.FindByValue(textOrValue));
}
else if (tempType == "dropdownlist")
{
if (isText)
((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByText(textOrValue));
else
((DropDownList)wc).SelectedIndex = ((DropDownList)wc).Items.IndexOf(((DropDownList)wc).Items.FindByValue(textOrValue));
}
else if (tempType == "radiobuttonlist")
{
if (isText)
((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByText(textOrValue));
else
((RadioButtonList)wc).SelectedIndex = ((RadioButtonList)wc).Items.IndexOf(((RadioButtonList)wc).Items.FindByValue(textOrValue));
}
}
谢谢大家的支持,帮我点下需要的广告谢谢我会更加努力整理我的百科服务大家
相关文章推荐
- 无误选择列表项的值或文本 listbox,dropdownlist,radiobuttonlist 函数
- ListBox,CheckBoxList,DropDownList,RadioButtonList的常见数据绑定
- ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法
- .NET常用控件绑定(DropDownList、RadioButtonList、CheckBoxList、ListBox、BulletedList)
- 【翻译】如何对RadioButtonList, DropDownList, ListBox等ListItem控件使用RequiredFieldValidator
- DataSet绑定ListBox、DropDownList、RadioButtonList、CheckBoxList控件
- ASP.NET中 RadioButtonList(单选按钮组),CheckBoxList(复选框组),DropDownList(下拉框),ListBox(列表框),BulletedList(无序列表)的使用前台绑定
- DataSet绑定ListBox、DropDownList、RadioButtonList、CheckBoxList控件
- ListBox,CheckBoxList,DropDownList,RadioButtonList的常见用法
- FileReader除了有函数readAsDataURL,另外还有另外两个函数readAsBinaryString 和 readAsText,分别可以将选择的文件读取成二进制和文本格式
- 选择checkBoxList|radiobuttonlist|dropdownlist 的的值
- Asp.Net之两个ListBox的列表项选择移动操作
- 选择checkBoxList|radiobuttonlist|dropdownlist 的的值
- php将HTML转换为txt文本的函数
- Ajax属性和函数以及 返回值之XML格式和文本格式(一)
- listbox动态选择模版
- asp.net实现DropDownList、ListBox无刷新三级联动(javascript)
- asp.net实现ListBox、DropDownList无刷新三级联动(xmlhttp)
- PowerShell控制台输出符号+函数参数类型指定+文本内容读取
- jQuery取得select选择的文本与值