我在测试的demo也不存在这个问题,在项目中存在这个问题
页面初始化的时候调用了初始化的方法在初始化中判断数据类型,如果数据类型为DATE类型,则设定控件的数据类型
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- Initialization();
- }
- }
- #region 数据初始化加载
- /// <summary>
- /// 数据初始化加载
- /// </summary>
- public void Initialization()
- {
- int tableID = 0;
- tableID = Convert.ToInt32(ID);
- DataImportClass.ShowData(FpSpread1, TASKID.ToString(), tableID.ToString());
- DataImportClass.ShowFarPoint(FpSpread1, tableID);
- }
- #endregion
- public static void ShowFarPoint(FpSpread fp, int ID)
- {
- //得到表名
- R_SUBJECT_RESULT_DEFINE model = WCFClientProvider.Wcf.ClientStandardServiceProvider.GetResultByID(ID.ToString());
- string tablename = "";
- if (model != null)
- tablename = model.RESULTTYPENAME;
- //得到配置表包含的列
- List<V_DB_DATAIMPORT> ColumnsList = WCFClientProvider.Wcf.ClientWorkServiceProvider.GetTableMessByID(ID, 0);
- SetFarPointStyle(fp, ColumnsList, tablename);
- fp.Sheets[0].RowCount = 20;
- }
- public static void SetFarPointStyle(FpSpread fp, List<V_DB_DATAIMPORT> ColumnsList, string TitleInfo)
- {
- int ColumCount = ColumnsList.Count;
- int RowCount = fp.Rows.Count;
- fp.Sheets[0].Columns.Count = ColumCount;
- fp.Sheets[0].ColumnHeader.RowCount = 1;
- //设置表名
- fp.TitleInfo.Visible = true;
- fp.TitleInfo.Height = 20;
- fp.TitleInfo.Text = TitleInfo;
- fp.TitleInfo.Font.Size = 15;
- fp.TitleInfo.Font.Bold = true;
- fp.TitleInfo.Font.Underline = true;
- //设置列名称
- for (int j = 0; j < ColumCount; j++)
- {
- if (ColumnsList[j].CTYPE == "DATE")
- {
- // fp.Sheets[0].Columns[ColumnsList[j].SN - 1].CellType = new FarPoint.Web.Spread.DateTimeCellType();
- FarPoint.Web.Spread.Extender.DateCalendarCellType dc = new FarPoint.Web.Spread.Extender.DateCalendarCellType();
- dc.Animated = true;
- dc.DateFormat = "yyyy/MM/dd";
- dc.EnableOnClient = true;
- AjaxControlToolkit.MaskedEditExtender mee = new AjaxControlToolkit.MaskedEditExtender();
- mee.Mask = "9999/99/99";
- mee.MaskType = AjaxControlToolkit.MaskedEditType.Date;
- mee.AutoComplete = true;
- mee.ClearMaskOnLostFocus = true;
- mee.ClipboardEnabled = true;
- mee.ClearTextOnInvalid = true;
- mee.MessageValidatorTip = false;
- dc.Extenders.Add(mee);
- dc.ShowEditor = false;
- fp.Sheets[0].Columns[ColumnsList[j].SN - 1].CellType = dc;
- }
复制代码 |