我正在做必填字段验证检查,首先我将“选择一个项目”硬编码到我的ddllocation
,但是当我点击提交按钮时,系统不会提示我必填字段消息。我错过了什么吗?
代码背后
ddlLocation.DataSource = dsResult.Tables[0];
ddlLocation.DataTextField = "location_nm";
ddlLocation.DataValueField = "location_id";
ddlLocation.DataBind();
ddlLocation.Items.Insert(0, "----Select an Item----");
HTML
<asp:RequiredFieldValidator ID="rfvLocation" runat="server"
ControlToValidate="ddlLocation"Display="Dynamic" CssClass="ErrorMsg"
ErrorMessage="Mandatory" InitialValue="1"></asp:RequiredFieldValidator>