Click here to Skip to main content
15,887,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all

I have a DropDownList for selecting some table names. Rather than placing a RequiredFieldValidator I preferred to write if-else code like this
C#
if
{  
    DropDownList.SelectedIndex==0;
    Label1.Visible = true
    Label1.Text = " Please Select Correct Table";

}

it is working properly when i first select any table name perfectly and then if i select the option "Select Table Name(SelectdIndex==0)"

but if i select "Select Table Name" option first time it's not working . Please tell me if u know where the problem is lying.
Posted
Updated 10-Mar-12 19:14pm
v2
Comments
ProEnggSoft 11-Mar-12 1:15am    
Edit: pre tag for C# code and var tags added - PES

1 solution

Not sure what you are doing , where is your if(condition), you can try setting the DropDownList property AutoPostBack="true".

for further queries comment here!

hope it helps :)
 
Share this answer
 
Comments
Jagan911 11-Mar-12 2:02am    
sorry for the wrong posting here is the corrected one
I have a DropDownList for selecting some table names. Rather than placing a RequiredFieldValidator I preferred to write if-else code like this
protected void DropDownList1_SelectedIndexChanged()
{
if(DropDownList.SelectedIndex==0)
{

Label1.Visible = true
Label1.Text = " Please Select Correct Table";
}
else
{
-----------
} it is working properly when i first select any table name perfectly and then if i select the option "Select Table Name(SelectdIndex==0)"

but if i select "Select Table Name" option first time it's not working . Please tell me if u know where the problem is lying.
Uday P.Singh 11-Mar-12 3:07am    
did you set the AutoPostBack="true" of Dropdownlist
Jagan911 11-Mar-12 3:10am    
of course i set "AutoPostBack" property of DropDownList to "true"

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