I am retrieving the DateTime from a db which is coming through in the Dropdown list as the full date and time. What i need is just the month from that DateTime in word format in that drop down list.
As below:
[System.Web.Services.WebMethod]
public static string OnChainChange(string ChainId)
{
DataTable table = DBHelper.GetMonthList(ChainId.Trim());
string result = string.Empty;
foreach (DataRow dr in table.Rows)
{
DateTime thisDate = Convert.ToDateTime(dr["FromDate"].ToString());
result += new ListItem(thisDate.ToString("MMMM"), thisDate.Month.ToString("MMMM"));
//result += dr["FromDate"].ToString() + ";";
}
return result;
}
LB - This question is different. I am trying to do this as a new listItem. I understand how to convert DateTime int. I would love you to find a duplicate answer to that! :)