Hello friend you need to something like this...
1) Set AutoPostback property of your both dropdown to True
2) Add SelectedIndexChanged event to your both dropdwon list
3) Make this type of method for binding data to grid and call that method inside
Dropdwon SelectedIndexChange event.
for your reference i made one demo method for binding data to grid.
protected void BindGridData()
{
string month, year;
month = ddlMonth.SelectedValue.ToString();
year = ddlYear.SelectedValue.ToString();
string selectQuery = string.Empty;
if (month != string.Empty && year != string.Empty)
{
selectQuery = "SELECT * FROM YOURTABLE WHERE MONTH = " + month + " AND year = "+ year;
}
else if (month != string.Empty && year == string.Empty)
{
selectQuery = "SELECT * FROM YOURTABLE WHERE MONTH = " + month;
}
else if (month == string.Empty && year != string.Empty)
{
selectQuery = "SELECT * FROM YOURTABLE WHERE year = "+ year;
}
}
this method is just for guide you, you need to write your own method for that as per your requirement.
4) And call that method something like this
protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e)
{
BindGridData();
}
protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e)
{
BindGridData();
}
try this it might help you.