//这里是HTML代码
<asp:DropDownList ID="ddlWorkType" runat="server" Width="150px"> </asp:DropDownList>
//这里在后台绑定值
DataSet workTypeDts = _publicCodeManager.GetCodeValues(((int)PersonnelPublicCodeType.JobProperty).ToString());
if (workTypeDts != null && workTypeDts.Tables[0].Rows.Count > 0)
{
ddlWorkType.Items.Add(new ListItem("", ""));
foreach (DataRow dr in workTypeDts.Tables[0].Rows)
{
ddlWorkType.Items.Add(new ListItem(dr[PSNStringResourcesSchema.RESOURCEVALUE_COLUMN].ToString(), dr[PSNPublicCodeItemSchema.PSNPUBLICCODEITEM_ITEMID_FULL].ToString()));
}
}
根据dropdownList的value值选中
document.getElementById("ddlWorkType").value = selectValue;
根据dropdownList的text值选中
var ddlhy = document.getElementById("ddlWorkType");
var profession = cell.Row.getCellFromKey("RESOURCEVALUE").getElement().innerText;
if (profession) {
for (var i = 0; i < ddlhy.options.length; i++) {
if (ddlhy.options[i].text == profession) {
ddlhy.options[i].selected = true;
}
}
}