ASP.NET Reset Controls to default values question

P

psinyc

this may be a simple thing ... I am trying to reset all
the page controls to their original setting, in the first
line of this method call (event). I want to dynamically
change the days of month in a dropdownlist list depending
on the users selected month in the month's
dropdownlist ... i am using AutoPostBack on the
dropdownlists ... can anyone offer suggestions? Thanks ..
here's the method ..

private void ddlStartMonth_SelectedIndexChanged(object
sender, System.EventArgs e)
{
// need to reset all page controls to original setting
if (ddlStartMonth.SelectedItem.Value == "2")
{
ddlStartDay.Items.RemoveAt(33);
ddlStartDay.Items.RemoveAt(32);
ddlStartDay.Items.RemoveAt(31);
}
else if (ddlStartMonth.SelectedItem.Value == "4")
{
ddlStartDay.Items.RemoveAt(33);
}
else if (ddlStartMonth.SelectedItem.Value == "6")
{
ddlStartDay.Items.RemoveAt(33);
}
else if (ddlStartMonth.SelectedItem.Value == "9")
{
ddlStartDay.Items.RemoveAt(33);
}
else if (ddlStartMonth.SelectedItem.Value == "11")
{
ddlStartDay.Items.RemoveAt(33);
}
}

what happens is the first month selected works, but now
the items have been removed from the dropdownlist, so the
second time the method is called, it's not working with
the full, default 31 day dropdownlist.

Sorry for the lengthy post, thanks ..
psinyc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top