//CurrentValue:绑定Dropdownlist后的选中项
public void BoundDropDownList(DropDownList dropDownList,string ColText,
string ColValue,DataTable dataTable,long CurrentValue)
{
dropDownList.DataSource=dataTable;
dropDownList.DataTextField=ColText;
dropDownList.DataValueField=ColValue;
dropDownList.DataBind();
foreach(ListItem item in dropDownList.Items)
{
try
{
if(Convert.ToInt64(item.Value)==CurrentValue)
{
item.Selected=true;
break;
}
}
catch
{
}
}
}

chengang0535 最后编辑于 2009-11-29 08:43:19