dropdown list

  • Thread starter Thread starter Yoshitha
  • Start date Start date
Y

Yoshitha

Hi

in my web form i had dropdown list

control and using items property i;ve

added
"--- select Item-----"
0
1
upto 10 numbers.

i also placed required field

validator control for this drop down

list.

when am running my application, if

click on submit button with out

selecting any value in the list then

it is storing 0 value at back end.
how to prompt the user to select the
value from dropdown list.

can anyone tell me how to do this.

thanx in advance.
yoshitha
 
Yoshita:
The following works:

<asp:ListBox ID="drop" Runat="server">
<asp:ListItem>0</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:ListBox>
<asp:RequiredFieldValidator ID="reqDrop" Runat="server"
ControlToValidate="drop" ErrorMessage="*" />
<asp:button id="btn" Runat="server" />

You'd need to show us some code so we can help you.

HOWEVER. If you are doing this in Firefox (or another browser which isn't
IE), client-side validation isn't going to work. In you button's OnClick
event, you'll need to add

Page.Validate()
If Page.IsValide then
..do your normal stuff here
end if

Karl
 
Back
Top