Hi all,
I have a class Functions as follows -
public class Functions
{
#region MonthsList
public void AddMonths(DropDownList ddl)
{
try
{
for (int i = 1; i <= 12; i++)
{
ddl.Items.Add(new ListItem(new DateTime(DateTime.Now.Year, i, 1).ToString("MMM"), i.ToString()));
}
}
catch (Exception err) { err.Message.ToString(); }
}
#endregion
#region YearsList
public void AddYears(DropDownList ddl)
{
try
{
for (int Year = 2010; Year <= DateTime.Now.Year+7; Year++)
{
ListItem li = new ListItem(Year.ToString(), Year.ToString());
ddl.Items.Add(li);
}
}
catch (Exception err) { err.Message.ToString(); }
}
#endregion
}
-------
Now, in Default.aspx Page, I have
4 Dropdownlist and 1 Radiobutton.
------------
Now, in Default.aspx.cs Page, the logic I want is as follows -
Page_Load Event()
{
Functions cf = new Functions();
cf.AddMonths(ddl_months_1);
cf.AddYears(ddl_years_1);
}
---------
Now, the user will select the Month and Year of his/her Choice.
Then the radio button will be visible. Till then, it is not visible.
I have 3 options in RadioButton -
1. Same Month
2. Next Month
3. Next To Next Month
---------------
Now,
If the User Selects Jan 2010 (from dropdownlists) and "Same Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Jan
ddl_years_2.selectedvalue =2010
If the User Selects Jan 2010 (from dropdownlists) and "Next Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Feb
ddl_years_2.selectedvalue =2010
If the User Selects Jan 2010 (from dropdownlists) and "Next To Next Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Mar
ddl_years_2.selectedvalue =2010
If the User Selects Dec 2010 (from dropdownlists) and "Same Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Dec
ddl_years_2.selectedvalue =2010
If the User Selects Dec 2010 (from dropdownlists) and "Next Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Jan
ddl_years_2.selectedvalue =2011
If the User Selects Dec 2010 (from dropdownlists) and "Next To NExt Month" (from radio button)
Then, the other dropdownlists' selected values must be
ddl_months_2.selectedvalue = Feb
ddl_years_2.selectedvalue =2011
----------------------
I am unable to form this logic.
PLease help.
Loading
Riddhi ValechaPosted Sep 24, 2014, 11:03 AM
I did not get your point.
How do I call this on Dropdownlist_selectedchangeindex event ?
I need this on RadioButtonList_SelectedindexChange event....
Please explain once again.
Riddhi ValechaPosted Sep 22, 2014, 11:18 PM
How do I do this?
I want the value selected on other dropdownlist based on values of previous dropdownlist and selected option of radioButtonList.
1. Assume that the previous Dropdownlist have values Jan 2010.
2. User selects a value from Radio Button List.
3. Then the other two dropdownlists will be visible and will have selected values.
---------
This is on RadioButton_SelectedIndexChange event.
---
Options of Radio Button are - 1. Same Month. 2. Next Month. 3. Next-to-Next Month.
--
1. Same Month - means other dropdownlist will have Jan 2010 as selected values.
2. Next Month - means other dropdownlist will have Feb 2010 as selected values.
3. Next To Next Month - means other dropdownlist will have Mar 2010 as selected values.
----------
For December 2010-
1. Same Month - means other dropdownlist will have Dec 2010 as selected values.
2. Next Month - means other dropdownlist will have Jan 2011 as selected values.
3. Next To Next Month - means other dropdownlist will have Feb 2011 as selected values.
--------------
Vithal WadjePosted Sep 22, 2014, 2:51 PM