Click here to Skip to main content
16,022,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have dropdown in my page which is having requiredfield validator. If I select an item from that dropdown selectedindexchanged event is firing. If i wont select anything from that dropdown message from requiredfieldvalidator will be shown. Now,
If I select an item selectedindexchanged event is not firing. Below is my code.

<asp:DropDownList ID="ddlCampuses"; runat="server"; OnSelectedIndexChanged="ddlCampuses_SelectedIndexChanged"; AutoPostBack="True" AppendDataBoundItems="True">/asp:DropDownList>
Posted
Updated 27-Apr-11 14:54pm
v2
Comments
raju melveetilpurayil 27-Apr-11 20:54pm    
[edit] edited for more readability[/edit]

Hi,
Make sure you do not manipulate DropDownList on server side code (.aspx.cs) again. Though you didnt post the full code snippet which is very helpful to find the actual problem, I think the code should be like this.
XML
<asp:DropDownList ID="ddlCampuses" runat="server" OnSelectedIndexChanged="ddlCampuses_SelectedIndexChanged" AutoPostBack="True" AppendDataBoundItems="True">
<asp:ListItem Value="-1" Selected="True">Select</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="* required" ControlToValidate="ddlCampuses" InitialValue="-1"></asp:RequiredFieldValidator>


Hope this will help.
 
Share this answer
 
Comments
rizwan muhammed khan gouri 26-Nov-12 0:56am    
sir will you please give me full details about two dropdown list on server side .i personaly used two dropdown list on single page with selectedindexchange but it fire page loag twice can you give me any solution for this.
Try to place your DropeDown into UpdatePanel..
<asp:UpdatePanel ID="upDivision" runat="server">
 <ContentTemplate>

place your dropeDown With requiredfield validator.

</ContentTemplate>

 <Triggers>
 <asp:AsyncPostBackTrigger ControlID="Your DropDown ID" EventName="SelectedIndexChanged" />

   </asp:UpdatePanel>


i hope it will help you...
 
Share this answer
 
Comments
dhilip mca 27-Apr-11 7:10am    
Thanks pratik. I tried your solution. But, Itdint work for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900