Hi akhter,
Please take reference to the below code and correct your code.
HTML
<asp:DropDownList ID="ddlMonths" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMonths_SelectedIndexChanged">
<asp:ListItem Value="Jan" Text="Jan"></asp:ListItem>
<asp:ListItem Value="Feb" Text="Feb"></asp:ListItem>
<asp:ListItem Value="Mar" Text="Mar"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
Code
C#
protected void ddlMonths_SelectedIndexChanged(object sender, EventArgs e)
{
String Mon;
Mon = ddlMonths.SelectedItem.Text;
int noofday;
if (Mon.ToUpper() == "FEB")
{
noofday = 28;
}
else
{
noofday = 31;
}
DropDownList2.Items.Clear();
for (int j = 1; j <= noofday; j++)
{
DropDownList2.Items.Add(new ListItem(j.ToString(), j.ToString()));
}
}