昨天刚刚用了NetAdvantage的WebDateChooser,发现他的属性中没日期的格式 ,只能显示文本属性,如this.WebDateChooser1.Text="2006-1-8" 我现在要求this.WebDateChooser1.Text="2006-01-08",不知道怎么转换 请指教!

解决方案 »

  1.   

    自己想了哈 已经实现了 private void WebDateChooser1_ValueChanged(object sender, Infragistics.WebUI.WebSchedule.WebDateChooser.WebDateChooserEventArgs e)
    {
    this.Label1.Text=this.WebDateChooser1.Text;
    //Response.Write(Convert.ToDateTime(this.Label1.Text));
                int    imonth=0,iday=0;
    string stryear = "",strmonth="",strday="";
    stryear = Convert.ToString(Convert.ToDateTime(this.Label1.Text).Year);
    imonth  = Convert.ToDateTime(this.Label1.Text).Month;
    iday    = Convert.ToDateTime(this.Label1.Text).Day;
    if (imonth<10)
    strmonth = "0" + imonth.ToString();
    else
    strmonth = imonth.ToString();
    if (iday<10)
    strday = "0" + iday.ToString();
    else
    strday = iday.ToString();
    StartDate = stryear + "-" + strmonth + "-" + strday + " 00:00:00";
                Response.Write(StartDate+"<br>");
    }