您的位置:首页 > 编程语言

控件数据初始值绑定代码

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: