控件数据初始值绑定代码
2011-09-13 17:38
267 查看
/// <summary>
/// 把ListControl(BulletedList、CheckBoxList、DropDownList、ListBox、RadioButtonList)指定值的行进行选择
/// </summary>
/// <param name="DLTarget">要操作的目标</param>
/// <param name="strValue">值</param>
public static void SelectItemByValue(ListControl DLTarget, string strValue)
{
if (strValue == "")
return;
int iCount = DLTarget.Items.Count;
for (int i = 0; i < iCount; i++)
if (DLTarget.Items[i].Value.Trim() == strValue)
{
DLTarget.SelectedIndex = i;
break;
}
return;
}
/// <summary>
/// 把ListControl(BulletedList、CheckBoxList、DropDownList、ListBox、RadioButtonList)指定名称的行进行选择
/// </summary>
/// <param name="DLTarget">要操作的目标</param>
/// <param name="strName">名称</param>
public static void SelectItemByName(ListControl DLTarget, string strName)
{
int iCount = DLTarget.Items.Count;
for (int i = 0; i < iCount; i++)
if (DLTarget.Items[i].Text == strName)
{
DLTarget.SelectedIndex = i;
break;
}
return;
}
/// 把ListControl(BulletedList、CheckBoxList、DropDownList、ListBox、RadioButtonList)指定值的行进行选择
/// </summary>
/// <param name="DLTarget">要操作的目标</param>
/// <param name="strValue">值</param>
public static void SelectItemByValue(ListControl DLTarget, string strValue)
{
if (strValue == "")
return;
int iCount = DLTarget.Items.Count;
for (int i = 0; i < iCount; i++)
if (DLTarget.Items[i].Value.Trim() == strValue)
{
DLTarget.SelectedIndex = i;
break;
}
return;
}
/// <summary>
/// 把ListControl(BulletedList、CheckBoxList、DropDownList、ListBox、RadioButtonList)指定名称的行进行选择
/// </summary>
/// <param name="DLTarget">要操作的目标</param>
/// <param name="strName">名称</param>
public static void SelectItemByName(ListControl DLTarget, string strName)
{
int iCount = DLTarget.Items.Count;
for (int i = 0; i < iCount; i++)
if (DLTarget.Items[i].Text == strName)
{
DLTarget.SelectedIndex = i;
break;
}
return;
}
相关文章推荐
- 控件数据初始值绑定代码
- C# 程序中如何向(DEV)ComboBoxEdit控件中添加下拉列表的值不使用数据绑定,就是使用代码添加
- winform快速开发平台之代码抽象->快速绑定ComboBox数据控件
- Winform开发常用控件之DataGridView的简单数据绑定——代码绑定DataSet、DataTable、IList、SqlDataReader
- 代码构建控件添加到界面并绑定数据
- Control Study -> 主表和子表数据同时在绑定控件显示(示例代码下载)
- 主表和子表数据同时在绑定控件显示(示例代码下载)
- Control Study -> 主表和子表数据同时在绑定控件显示(示例代码下载)
- Repeater控件绑定数据、分页、数据操作,最佳代码
- Repeater控件绑定数据、分页、数据操作,最佳代码
- treeview 控件动态绑定数据部分实例代码
- treeview 控件动态绑定数据部分实例代码
- C#中对控件的非代码数据绑定操作(WEB FORM)
- Control Study -> 主表和子表数据同时在绑定控件显示(示例代码下载)
- Repeater控件绑定数据、分页、数据操作,最佳代码
- 《论不使用ObjectDataSource之数据绑定控件纯代码实现是否更优化? 》补记
- WPF的数据绑定之控件源绑定以及代码方式绑定
- treeview 控件动态绑定数据部分实例代码
- 关于webform中控件的列表数据的绑定
- 如何让GridView控件在绑定的数据源没有数据时也显示标题