<
asp:DropDownList
ID
="
ddlTown
"
runat
="server"
>
<
asp:ListItem
Value
="-1"
>
---選擇鄉鎮---
</
asp:ListItem
>
<
asp:ListItem
Value
="沂城街道"
>
沂城街道
</
asp:ListItem
>
<
asp:ListItem
Value
="道托鎮"
>
道托鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="高橋鎮"
>
高橋鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="馬站鎮"
>
馬站鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="楊莊鎮"
>
楊莊鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="富官莊鎮"
>
富官莊鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="圈里鄉"
>
圈里鄉
</
asp:ListItem
>
<
asp:ListItem
Value
="沙溝鎮"
>
沙溝鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="諸葛鎮"
>
諸葛鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="泉莊鎮"
>
泉莊鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="龍家圈鎮"
>
龍家圈鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="黃山鋪鎮"
>
黃山鋪鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="崔家峪"
>
崔家峪
</
asp:ListItem
>
<
asp:ListItem
Value
="夏蔚鎮"
>
夏蔚鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="高莊鎮"
>
高莊鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="沂蒙風情旅游區(院東頭鎮)"
>
沂蒙風情旅游區(院東頭鎮)
</
asp:ListItem
>
<
asp:ListItem
Value
="許家湖鎮"
>
許家湖鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="四十里鎮"
>
四十里鎮
</
asp:ListItem
>
<
asp:ListItem
Value
="開發區"
>
開發區
</
asp:ListItem
>
</
asp:DropDownList
>
<
asp:CustomValidator
ID
="CustomValidator1"
runat
="server"
ErrorMessage
="*請選擇鄉鎮"
ClientValidationFunction
="ChkDropDownList"
ControlToValidate
="ddlTown"
></
asp:CustomValidator
>
function
ChkDropDownList(source, args) {
if
(args.Value == "-1"
)//當下拉菜單選擇的是-1的時候,就是沒有選擇
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
;
}
}