Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
int count = Convert.ToInt16(ddlvehicles.SelectedValue);
        for (int i = 2; i <= count; i++)
        {
            ((Panel)mvbooking.Views[0].FindControl("Panel" + i)).Visible = true;
        }



here when i select values 2 or more.. in ddl then panel is visible but when i select 5 and then 2 then also 5 panels are seen..

it means i want to see panel upto the selected value in ddl...
Posted
Comments
Maciej Los 18-Mar-13 13:42pm    
Member 9671810 18-Mar-13 13:50pm    
i have dropdownlist having values 1 to 10, and panel 1 to 10. after writing dis code when i select 5 in dropdownlist panel is visible upto 5, bt after that if i select 2 then 2 panel should be visible which is not working.. i mean i don't know dat logic.
Jegan Thiyagesan 18-Mar-13 13:44pm    
Can you add bit more sense to your question?
What are you trying to achieve?
What are you trying to avoid?
Member 9671810 18-Mar-13 13:50pm    
i have dropdownlist having values 1 to 10, and panel 1 to 10. after writing dis code when i select 5 in dropdownlist panel is visible upto 5, bt after that if i select 2 then 2 panel should be visible which is not working.. i mean i don't know dat logic.
Member 9581488 18-Mar-13 14:39pm    
post your aspx dropdown code and one panel code.

It seems to be easy to develop...
You need to hide panels which id is bigger then currently selected panel, and show panels which id's are smaller or equal to currently selected panel. Try below code:
C#
int count = ddlvehicles.Count; //i hope you know how to get count of panels
int cursel = ddlvehicles.SelectedValue; 
for (int i = count; i >2 ; i--)
{
    ((Panel)mvbooking.Views[0].FindControl("Panel" + i)).Visible = (i<=cursel);
}
 
Share this answer
 
C#
for(count++;count<=ddlvehicles.Items.Count;count++)
        {
            ((Panel)mvbooking.Views[0].FindControl("Panel" + count)).Visible = false;
        }


write dis after dat code..
 
Share this answer
 
Comments
Maciej Los 19-Mar-13 8:19am    
Is it anwer?
Jegan Thiyagesan 19-Mar-13 10:16am    
How this would work?
Member 9671810 19-Mar-13 13:16pm    
yup..
and it worked for me.......
after writing both for loops

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