i have the following fields: type(dropdownlist)---->ExhibitionMonth(dropdownlist)----> All monthsYear(dropdownlist)-----> Years till 2049
when i click on view link button,it display all the events of the selected month and year.
I want the same result but on pageload.i am selecting exhibition then i am selecting month and then i am selecting year and clicking on view link button and i am getting the required result.
what i want is Exhibition, current month and current year should be selected by default on Page load.how to achieve that?
<div id="divCrmInformation1" style="border-bottom: 1px dotted; border-color: #0a7898;
height: 560px; margin-top: 15px; margin-right: 20px; margin-bottom: 5px;">
<div class="homeDivHdr">
Upcoming Exhibitions</div>
<table>
<tr>
<td align="right" valign="top">
Type :<br />
</td>
<td align="left">
</td>
<td align="left" valign="top">
<asp:DropDownList ID="lstType" runat="server" Width="210px" Height="26px">
<asp:ListItem Value='--Select--' Selected="True">--Select--</asp:ListItem>
<asp:ListItem Value="Exhibition">Exhibition</asp:ListItem>
</asp:DropDownList>
</td>
<td align="right" valign="top">
Month :
</td>
<td align="left">
</td>
<td align="left" valign="top">
<asp:DropDownList ID="lstMonth" runat="server" Width="210px" Height="26px">
<asp:ListItem Value='--Select--' Selected="True">--Select Month--</asp:ListItem>
<asp:ListItem>January</asp:ListItem>
<asp:ListItem>Febuary</asp:ListItem>
<asp:ListItem>March</asp:ListItem>
<asp:ListItem>April</asp:ListItem>
<asp:ListItem>May</asp:ListItem>
<asp:ListItem>June</asp:ListItem>
<asp:ListItem>July</asp:ListItem>
<asp:ListItem>August</asp:ListItem>
<asp:ListItem>September</asp:ListItem>
<asp:ListItem>October</asp:ListItem>
<asp:ListItem>November</asp:ListItem>
<asp:ListItem>December</asp:ListItem>
</asp:DropDownList>
</td>
<td align="right" valign="top">
Year :
</td>
<td align="left">
</td>
<td align="left" valign="top">
<asp:DropDownList ID="lstYear" runat="server" Width="210px" Height="26px">
<asp:ListItem Value='--Select--' Selected="True">--Select Year--</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="buttView" CssClass="buttSearch buttMagine" ForeColor="White" runat="server"
Text="View Link" OnClick="buttContact_Click" BorderStyle="None" Height="25px"
Width="90px" />
</td>
</tr>
</table>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;
lstMonth.SelectedIndex = month;
lstYear.SelectedIndex = year;
setYears();
}
}
protected void setYears()
{
for (int i = 1990; i < 2050; i++)
lstYear.Items.Add(i.ToString());
}