private void InitControl() { string queryItemId = this.Page.Request.Params["queryItemId"]; if (queryItemId == null) { showMessage.Text = "您还没选择查询业务!"; return; } ItemFile = Page.Server.MapPath(DataPath + "items/" + queryItemId + ".item"); getInputType(); Label descriptionText = new Label(); descriptionText.Text = this.Description; p.Controls.Add(descriptionText); IEnumerator inputTypeEnumerator = InputType.GetEnumerator(); IEnumerator fieldChineseNameEnumerator = FieldChineseName.GetEnumerator(); IEnumerator nameListEnumerator = NameList.GetEnumerator(); IEnumerator initDataEnumerator = InitData.GetEnumerator(); while (inputTypeEnumerator.MoveNext() && fieldChineseNameEnumerator.MoveNext() && nameListEnumerator.MoveNext() && initDataEnumerator.MoveNext()) { string type = ((DictionaryEntry)inputTypeEnumerator.Current).Value.ToString(); string chinesefieldname = ((DictionaryEntry)fieldChineseNameEnumerator.Current).Value.ToString(); string name = ((DictionaryEntry)nameListEnumerator.Current).Value.ToString(); string datalist = ((DictionaryEntry)initDataEnumerator.Current).Value.ToString(); Control c = CreateControl(type, chinesefieldname, name, datalist); CurrentControls.Add(c); } }
protected override void AttachChildControls() { p = (Panel)FindControl("P"); t = (Table)FindControl("T"); showMessage = (Label)FindControl("showMessage"); saveButton = FindControl("Save") as Button; queryButton = FindControl("Query") as Button; queryButton.Click += new EventHandler(queryButton_Click); saveButton.Click += new EventHandler(saveButton_Click); if (!Page.IsPostBack) { InitControl(); } else { Label descriptionText = new Label(); descriptionText.Text = this.Description; p.Controls.Add(descriptionText); IEnumerator inputTypeEnumerator = InputType.GetEnumerator(); IEnumerator fieldChineseNameEnumerator = FieldChineseName.GetEnumerator(); IEnumerator nameListEnumerator = NameList.GetEnumerator(); IEnumerator initDataEnumerator = InitData.GetEnumerator(); while (inputTypeEnumerator.MoveNext() && fieldChineseNameEnumerator.MoveNext() && nameListEnumerator.MoveNext() && initDataEnumerator.MoveNext()) { string type = ((DictionaryEntry)inputTypeEnumerator.Current).Value.ToString(); string chinesefieldname = ((DictionaryEntry)fieldChineseNameEnumerator.Current).Value.ToString(); string name = ((DictionaryEntry)nameListEnumerator.Current).Value.ToString(); string datalist = ((DictionaryEntry)initDataEnumerator.Current).Value.ToString(); Control c = CreateControl(type, chinesefieldname, name, datalist); CurrentControls.Add(c); } } }