Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Validation for DropDown List

Status
Not open for further replies.

livezone

MIS
Jan 17, 2003
81
CA
Hi
I have created a Drop Down list with a validation required. I added a field dynamically at the start which will be the initial value

Dim dtrDepartment As SqlDataReader
dtrDepartment = cmdDepartment.ExecuteReader()
dropDepartment.DataSource = dtrDepartment
dropDepartment.DataValueField = "Department_ID"
dropDepartment.DataTextField = "Department_Text"
dropDepartment.DataBind()
dtrDepartment.Close()
rfdvDepartment.InitialValue = lblDepartment.Text
dropDepartment.Items.Insert(0, New ListItem(lblDepartment.Text, -1))


Validation is like that

<asp:RequiredFieldValidator ID=&quot;rfdvDeparmtnet&quot; Runat=&quot;server&quot; ErrorMessage=&quot;Select your Store/Department&quot; ControlToValidate=&quot;DropDepartment&quot; Display=&quot;Dynamic&quot;></asp:RequiredFieldValidator>

As it shows the inital value as &quot;Select Department&quot; but it did not give me an error message if someone did not select anyother value than &quot;Select Department&quot;

Please guide
Thanks
 
Ignore it.

I have found the solution

rfdvDepartment.InitialValue = -1

will work

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top