<
asp:DropDownList
ID
="
ddlTown
"
runat
="server"
>
<
asp:ListItem
Value
="-1"
>
---選擇鄉(xiāng)鎮(zhèn)---
</
asp:ListItem
>
<
asp:ListItem
Value
="沂城街道"
>
沂城街道
</
asp:ListItem
>
<
asp:ListItem
Value
="道托鎮(zhèn)"
>
道托鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="高橋鎮(zhèn)"
>
高橋鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="馬站鎮(zhèn)"
>
馬站鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="楊莊鎮(zhèn)"
>
楊莊鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="富官莊鎮(zhèn)"
>
富官莊鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="圈里鄉(xiāng)"
>
圈里鄉(xiāng)
</
asp:ListItem
>
<
asp:ListItem
Value
="沙溝鎮(zhèn)"
>
沙溝鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="諸葛鎮(zhèn)"
>
諸葛鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="泉莊鎮(zhèn)"
>
泉莊鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="龍家圈鎮(zhèn)"
>
龍家圈鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="黃山鋪鎮(zhèn)"
>
黃山鋪鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="崔家峪"
>
崔家峪
</
asp:ListItem
>
<
asp:ListItem
Value
="夏蔚鎮(zhèn)"
>
夏蔚鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="高莊鎮(zhèn)"
>
高莊鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="沂蒙風(fēng)情旅游區(qū)(院東頭鎮(zhèn))"
>
沂蒙風(fēng)情旅游區(qū)(院東頭鎮(zhèn))
</
asp:ListItem
>
<
asp:ListItem
Value
="許家湖鎮(zhèn)"
>
許家湖鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="四十里鎮(zhèn)"
>
四十里鎮(zhèn)
</
asp:ListItem
>
<
asp:ListItem
Value
="開發(fā)區(qū)"
>
開發(fā)區(qū)
</
asp:ListItem
>
</
asp:DropDownList
>
<
asp:CustomValidator
ID
="CustomValidator1"
runat
="server"
ErrorMessage
="*請(qǐng)選擇鄉(xiāng)鎮(zhèn)"
ClientValidationFunction
="ChkDropDownList"
ControlToValidate
="ddlTown"
></
asp:CustomValidator
>
function
ChkDropDownList(source, args) {
if
(args.Value == "-1"
)//當(dāng)下拉菜單選擇的是-1的時(shí)候,就是沒有選擇
args.IsValid
=
false
;
else
args.IsValid
=
true
;
}
public
void
selectValue(DropDownList ddl,
string
value)
{
foreach
(ListItem item
in
ddl.Items)
{
if
(value ==
item.Value)
item.Selected
=
true
;
}
}