In my webpage I have two dropdown controls for namely ddlmonth and ddldays ( for month & days)
I write a method for current month in ddlmonth and current day in ddldays and i call that method in page load event it working fien but when i select (in ddlmonth ) different month and different day and insert into database the values inserted in database is current month and current day, actually i select different month and day
This is my code
This is the method for current date display in ddlmonth dropdwon control and ddlday
public void getMonth()
{
ddlmonth.SelectedIndex = DateTime.Now.Month -1;
ddldate.SelectedIndex = DateTime.Now.Day - 1;
}
I call this in page load
protected void Page_Load(object sender, EventArgs e)
{
getMonth();
}
If I call the getMonth method in postback
protected void Page_Load(object sender, EventArgs e)
{
if(!ispostback)
{
getMonth();
}
}
it not displaying the current month and date
without postback it is working
When I select different month and day and insert into database it is taking current month and day
Please help me
You can try to use Request.Form[“ddlmonth”] and Request.Form[“ddlday”] to retrieve the values.