/// <summary> /// 页面初始话 /// </summary> /// <param name="WorkflowID"></param> /// <param name="IsAgent"></param> private void InitPageContent(int WorkflowID, int FormID, int NodeID) { //placeHolder.Controls.Clear(); //DataTable dtMainField = DbHelper.GetInstance().sp_GetMainFieldInforByNodeIDAndFormID(FormID, NodeID); dtMainField = DbHelper.GetInstance().sp_GetMainFieldInforByNodeIDAndFormID(FormID, NodeID); //a.FieldID,a.IsView,a.IsEdit,a.IsMandatory,a.BasicValidType,a.ValidTimeType,e.ValidTimeTypeName,b.FieldLabel,c.FieldName,c.FieldDBType,c.HTMLTypeID,c.TextLength,c.TextHeight,c.BrowseType,c.IsDynamic,c.DataSetID,c.valueColumn,c.TextColumn,c.CSSStyle,f.CSSStyleClass,f.LineLength,c.DefaultValue int IsNewLine = 0; int LineLength = 0; Literal literialStart = new Literal(); literialStart.ID = "lblMainFieldStart"; literialStart.Text = "<div class='clear'>"; placeHolder.Controls.Add(literialStart); for (int i = 0; i < dtMainField.Rows.Count; i++) { string FieldID = dtMainField.Rows[i]["FieldID"].ToString(); string FieldName = dtMainField.Rows[i]["FieldName"].ToString(); string FieldLable = dtMainField.Rows[i]["FieldLabel"].ToString(); string FieldDataType = dtMainField.Rows[i]["FieldDBType"].ToString(); string SqlDbType = dtMainField.Rows[i]["SqlDbType"].ToString(); int SqlDbLength = Convert.ToInt32(dtMainField.Rows[i]["SqlDbLength"]); int FieldCCSStyle = Convert.ToInt32(dtMainField.Rows[i]["CSSStyle"].ToString()); string FieldCSSStyleClass = dtMainField.Rows[i]["CSSStyleClass"].ToString(); int FieldLineLength = Convert.ToInt32(dtMainField.Rows[i]["LineLength"].ToString()); string FieldDefaultValue = dtMainField.Rows[i]["DefaultValue"].ToString(); int FieldHTMLTypeID = Convert.ToInt32(dtMainField.Rows[i]["HTMLTypeID"].ToString()); int FieldTextLength = Convert.ToInt32(dtMainField.Rows[i]["TextLength"].ToString()); int FieldTextHeight = Convert.ToInt32(dtMainField.Rows[i]["TextHeight"].ToString()); int FieldValidType = Convert.ToInt32(dtMainField.Rows[i]["BasicValidType"].ToString()); string ValidTimeTypeName = dtMainField.Rows[i]["ValidTimeTypeName"].ToString(); int IsView= Convert.ToInt32(dtMainField.Rows[i]["IsView"].ToString()); int IsEdit = Convert.ToInt32(dtMainField.Rows[i]["IsEdit"].ToString()); int IsDynamic = Convert.ToInt32(dtMainField.Rows[i]["IsDynamic"].ToString()); int DataSetID = Convert.ToInt32(dtMainField.Rows[i]["DataSetID"].ToString()); string ValueColumn = dtMainField.Rows[i]["valueColumn"].ToString(); string TextColumn = dtMainField.Rows[i]["TextColumn"].ToString(); int IsMandatory = Convert.ToInt32(dtMainField.Rows[i]["IsMandatory"].ToString()); int FieldDataTypeID = Convert.ToInt32(dtMainField.Rows[i]["DataTypeID"].ToString()); string FieldDateFormat = dtMainField.Rows[i]["Dateformat"].ToString(); if (IsView == 1) { Literal lblFieldDesc = new Literal(); lblFieldDesc.ID = "lblField" + FieldID + "Desc"; LineLength = LineLength + FieldLineLength; if (LineLength > 3) { IsNewLine = 1; LineLength = FieldLineLength; } else { IsNewLine = 0; } if (IsNewLine == 1) { lblFieldDesc.Text = "</div><div class='clear'><div class=" + FieldCSSStyleClass + "><label class='char5'>" + FieldLable + "</label><div class='iptblk'>"; } else { lblFieldDesc.Text = "<div class=" + FieldCSSStyleClass + "><label class='char5'>" + FieldLable + "</label><div class='iptblk'>"; } placeHolder.Controls.Add(lblFieldDesc); switch (FieldHTMLTypeID) { case 1: //Label Label lblField = new Label(); lblField.ID = "field" + FieldID; lblField.Text = FieldDefaultValue; placeHolder.Controls.Add(lblField); break; case 2: //Textbox GPRP.GPRPControls.TextBox txtField = new GPRP.GPRPControls.TextBox(); txtField.ID = "field" + FieldID; txtField.Text = FieldDefaultValue; txtField.Width = new Unit(120); if (FieldValidType > 0) //有数据验证 { txtField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } if (IsEdit == 0) { txtField.Enabled = false; } else { if (IsMandatory == 1) { txtField.CanBeNull = "必填"; } DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } placeHolder.Controls.Add(txtField); if (IsEdit == 1) { //如果是时间或日期 if (FieldDataTypeID == 4 || FieldDataTypeID == 5) { //txtField.AddAttributes("readonly", "true"); Literal literialImage = new Literal(); literialImage.Text = "<img onclick=\"WdatePicker({el:$dp.$('" + txtField.ID + "'),dateFmt:'" + FieldDateFormat + "'})\" src=\"../images/calendar.gif\">"; literialImage.ID = "fieldImage" + FieldID; //ImageButton imageButton = new ImageButton(); //imageButton.ID = "fieldImage" + FieldID; //imageButton.ImageAlign = ImageAlign.Middle; //imageButton.ToolTip = "搜索"; //imageButton.ImageUrl = "../images/calendar.gif"; ////imageButton.OnClientClick = "return btnBrowseFieldClick('" + txtBrowseField.ID + "','" + txtBrowseFieldValue.ID + "','" + BrowsePage + "','" + BrowseTypeName + "');"; ////imageButton.Attributes.Add("onclik", "javascript:WdatePicker({dateFmt:'" + FieldDateFormat + "'})"); //imageButton.OnClientClick = "return WdatePicker({el:$dp.$('" + txtField .ID+ "'),dateFmt:'" + FieldDateFormat + "'})"; placeHolder.Controls.Add(literialImage); txtField.AddAttributes("onfocus", "javascript:WdatePicker({dateFmt:'" + FieldDateFormat + "'})"); } } break; case 3: //TextArea GPRP.GPRPControls.TextBox txtAreaField = new GPRP.GPRPControls.TextBox(); txtAreaField.ID = "field" + FieldID; txtAreaField.TextMode = TextBoxMode.MultiLine; txtAreaField.Width = new Unit(FieldTextLength == 0 ? 300 : FieldTextLength); txtAreaField.Rows = FieldTextHeight; txtAreaField.Text = FieldDefaultValue; if (FieldValidType > 0) //有数据验证 { txtAreaField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } if (IsEdit == 0) { txtAreaField.Enabled = false; } else { if (IsMandatory == 1) { txtAreaField.CanBeNull = "必填"; } DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } placeHolder.Controls.Add(txtAreaField); break; case 4: //checkboxList GPRP.GPRPControls.CheckBoxList chkLstField = new GPRP.GPRPControls.CheckBoxList(); //chkLstField.CssClass = "buttonlist"; chkLstField.ID = "field" + FieldID; chkLstField.RepeatColumns = 1; chkLstField.RepeatDirection = RepeatDirection.Vertical; //获得数据源 DataTable dtList = DbHelper.GetInstance().GetMultiSelectDataSource(Convert.ToInt32(FieldID), IsDynamic, DataSetID, ValueColumn, TextColumn); chkLstField.AddTableData(dtList); chkLstField.DataTextField = TextColumn; chkLstField.DataValueField = ValueColumn; //有数据验证 if (FieldValidType > 0) { chkLstField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } if (IsEdit == 0) { chkLstField.Enabled = false; } else { DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } placeHolder.Controls.Add(chkLstField); break; case 5: // dropdownlist GPRP.GPRPControls.DropDownList ddlField = new GPRP.GPRPControls.DropDownList(); ddlField.ID = "field" + FieldID; //ddlField.RepeatColumns = 1; //ddlField.RepeatDirection = RepeatDirection.Vertical; //chkLstField.AddTableData() ddlField.Width = new Unit(120); DataTable dtDrop = DbHelper.GetInstance().GetMultiSelectDataSource(Convert.ToInt32(FieldID), IsDynamic, DataSetID, ValueColumn, TextColumn); ddlField.AddTableData(dtDrop); ddlField.DataTextField = TextColumn; ddlField.DataValueField = ValueColumn; ddlField.SelectedValue = FieldDefaultValue; //有数据验证 if (FieldValidType > 0) { ddlField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } if (IsEdit == 0) { ddlField.Enabled = false; } else { DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } placeHolder.Controls.Add(ddlField); break; case 6: //checkbox System.Web.UI.WebControls.CheckBox chkField = new System.Web.UI.WebControls.CheckBox(); chkField.ID = "field" + FieldID; //ddlField.RepeatColumns = 1; //ddlField.RepeatDirection = RepeatDirection.Vertical; //chkLstField.AddTableData() if (FieldDefaultValue.ToUpper() == "TRUE" || FieldDefaultValue == "1") chkField.Checked = true; if (FieldValidType > 0) //有数据验证 { chkField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } if (IsEdit == 0) { chkField.Enabled = false; } else { DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } placeHolder.Controls.Add(chkField); break; case 7: //uploadFile FileUploadControl fileUpLoad = (FileUploadControl)(Page.LoadControl("UserControl/FileUploadControl.ascx")); fileUpLoad.WorkflowID = WorkflowID; fileUpLoad.RequestID = RequestID; fileUpLoad.Uploader = userEntity.UserSerialID; fileUpLoad.FieldID = Convert.ToInt32(FieldID); fileUpLoad.IsEdit = IsEdit; fileUpLoad.RightType = RightType; if (IsEdit == 1) { fileUploadGroup.Add(fileUpLoad); } placeHolder.Controls.Add(fileUpLoad); break; case 8: //浏览形式按钮 string BrowsePage = dtMainField.Rows[i]["BrowsePage"].ToString(); string BrowseTypeName = dtMainField.Rows[i]["BrowseTypeName"].ToString(); GPRP.GPRPControls.TextBox txtBrowseField = new GPRP.GPRPControls.TextBox(); txtBrowseField.ID = "fieldText" + FieldID; txtBrowseField.Width = new Unit(120); System.Web.UI.WebControls.HiddenField txtBrowseFieldValue = new System.Web.UI.WebControls.HiddenField(); txtBrowseFieldValue.ID = "field" + FieldID; //有数据验证 if (FieldValidType > 0) { txtBrowseField.Attributes.Add(ValidTimeTypeName, "javascript:FormFieldValidate('" + FieldID + "','" + FieldHTMLTypeID.ToString() + "','" + FieldValidType.ToString() + "')"); } txtBrowseField.AddAttributes("readonly", "true"); placeHolder.Controls.Add(txtBrowseField); if (IsEdit == 1) { ImageButton imageButton = new ImageButton(); imageButton.ID = "fieldImage" + FieldID; imageButton.ImageAlign = ImageAlign.Middle; imageButton.ToolTip = "搜索"; imageButton.ImageUrl = "../images/arrow_black.gif"; imageButton.OnClientClick = "return btnBrowseFieldClick('" + txtBrowseField.ID + "','" + txtBrowseFieldValue.ID + "','" + BrowsePage + "','" + BrowseTypeName + "');"; placeHolder.Controls.Add(imageButton); if (IsMandatory == 1) { txtBrowseField.CanBeNull = "必填"; } placeHolder.Controls.Add(txtBrowseFieldValue); DataRow row = dtMainEdit.NewRow(); row["FieldID"] = FieldID; row["FieldName"] = FieldName; row["FieldDataType"] = FieldDataType; row["SqlDbType"] = SqlDbType; row["SqlDbLength"] = SqlDbLength; row["FieldHTMLType"] = FieldHTMLTypeID; dtMainEdit.Rows.Add(row); } else { txtBrowseField.Enabled = false; } break; case 9: // GroupLine if (IsEdit == 1) //可编辑时才用 { string GroupLineDataSetID = dtMainField.Rows[i]["GroupLineDataSetID"].ToString(); string TargetGroupID = dtMainField.Rows[i]["TargetGroupID"].ToString(); ImageButton imageButton = new ImageButton(); imageButton.ID = "field" + FieldID; imageButton.ImageAlign = ImageAlign.Middle; imageButton.ToolTip = "搜索"; imageButton.ImageUrl = "../images/BacoBrowser.gif"; imageButton.OnClientClick = "return btnGroupLineFieldClick('" + FieldID + "','" + GroupLineDataSetID + "','" + TargetGroupID + "');"; imageButton.Click += new ImageClickEventHandler(imageGroupLineButton_Click); placeHolder.Controls.Add(imageButton); } break; } if (IsEdit == 1 && IsMandatory == 1) { Label literialMandatory = new Label(); literialMandatory.ID = "lblFieldMandatory" + FieldID; literialMandatory.Text = "*"; literialMandatory.ForeColor = System.Drawing.Color.Red; placeHolder.Controls.Add(literialMandatory); } Literal literial = new Literal(); literial.ID = "lblField" + FieldID + "End"; literial.Text = "</div></div>"; placeHolder.Controls.Add(literial); } } Literal literialEnd = new Literal(); literialEnd.ID = "lblMainFieldEnd"; literialEnd.Text = "</div>"; placeHolder.Controls.Add(literialEnd); //下面是明细字段 //抓明细字段组 DataTable dtDetailGroup = DbHelper.GetInstance().GetDetailFieldGroup(FormID, NodeID); if (dtDetailGroup.Rows.Count > 0) { //先添加tabcontainer. AjaxControlToolkit.TabContainer tabContainer = new AjaxControlToolkit.TabContainer(); tabContainer.ID = "tabContainer"; for (int j = 0; j < dtDetailGroup.Rows.Count; j++) { //添加tab ,tab中添加FormDetailGroup //a.GroupID,a.IsView,a.IsAdd,a.IsEdit,a.IsDelete,b.GroupName int GroupID = Convert.ToInt32(dtDetailGroup.Rows[j]["GroupID"].ToString()); int IsView = Convert.ToInt32(dtDetailGroup.Rows[j]["IsView"].ToString()); int IsEdit = Convert.ToInt32(dtDetailGroup.Rows[j]["IsEdit"].ToString()); int IsDelete = Convert.ToInt32(dtDetailGroup.Rows[j]["IsDelete"].ToString()); int IsAdd = Convert.ToInt32(dtDetailGroup.Rows[j]["IsAdd"].ToString()); string GroupName = dtDetailGroup.Rows[j]["GroupName"].ToString(); AjaxControlToolkit.TabPanel tablePanel = new AjaxControlToolkit.TabPanel(); tablePanel.HeaderText = GroupName; tablePanel.ID = "TP" + GroupID.ToString(); //tablePanel.Height = new Unit(400); FormDetailGroup detailGroup = (FormDetailGroup)(Page.LoadControl("UserControl/FormDetailGroup.ascx")); detailGroup.FormID = FormID; detailGroup.GroupID = GroupID; detailGroup.WorkflowID = WorkflowID; detailGroup.RequestID = RequestID; detailGroup.IsGroupView = IsView; detailGroup.IsGroupEdit = IsEdit; detailGroup.IsGroupAdd = IsAdd; detailGroup.IsGroupDelete = IsDelete; detailGroup.NodeID = NodeID; detailGroup.dtField = DbHelper.GetInstance().GetDetailFieldInfor(NodeID, GroupID); detailGroup.RightType = RightType; Panel panel = new Panel(); panel.Height = new Unit(100); panel.ID = tablePanel.ID + "panel"; panel.Controls.Add(detailGroup); tablePanel.Controls.Add(panel); tabContainer.Tabs.Add(tablePanel); if (IsEdit == 1 || IsAdd == 1 || IsDelete == 1) { detailGroups.Add(detailGroup); } } tabContainer.ActiveTabIndex = 0; placeHolderDetail.Controls.Add(tabContainer); } }
private void bindGridView() { DataTable dtMainField = new DataTable(); dtMainField = DbHelper.GetInstance().GetWorkflow_UserDefinedReportTableByReportID(DNTRequest.GetString("ReportID")); GridView1.DataSource = dtMainField; GridView1.DataBind(); for (int i = 0; i < dtMainField.Rows.Count; i++) { string FieldID = dtMainField.Rows[i]["FieldID"].ToString(); string FieldName = dtMainField.Rows[i]["FieldName"].ToString(); int DataTypeID = Convert.ToInt32(dtMainField.Rows[i]["DataTypeID"]); string FieldDefaultValue = dtMainField.Rows[i]["DefaultValue"].ToString(); int FieldHTMLTypeID = Convert.ToInt32(dtMainField.Rows[i]["HTMLTypeID"].ToString()); int FieldTextLength = Convert.ToInt32(dtMainField.Rows[i]["TextLength"].ToString()); int FieldTextHeight = Convert.ToInt32(dtMainField.Rows[i]["TextHeight"].ToString()); int IsDynamic = Convert.ToInt32(dtMainField.Rows[i]["IsDynamic"].ToString()); int DataSetID = Convert.ToInt32(dtMainField.Rows[i]["DataSetID"].ToString()); string ValueColumn = dtMainField.Rows[i]["ValueColumn"].ToString(); string TextColumn = dtMainField.Rows[i]["TextColumn"].ToString(); switch (FieldHTMLTypeID) { case 1: //Label break; case 2: //Textbox //根据数据类型,来判断要创建的比较符dropdownlist的数据源 //如果数据类型DataTypeID=1,2,3是文本,直接加一个textbox //DataTypeID=4,再加两个日期选择textbox, 两个比较符dropdownlist if (DataTypeID == 1 || DataTypeID == 2 || DataTypeID == 3) { CreateCompareDropDownList(i, Int32.Parse(FieldID), DataTypeID); GPRP.GPRPControls.TextBox txtField = new GPRP.GPRPControls.TextBox(); txtField.ID = "field" + FieldID; txtField.Text = FieldDefaultValue; txtField.Width = new Unit(100); if (DataTypeID == 2 || DataTypeID == 3) { txtField.Attributes.Add("onkeypress", "javascript: return checkkey(this.value,event);"); } txtField.Attributes.Add("onkeydown", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(txtField); } else { //如果是日期类型 CreateDateTimeTypeFieldControl(i, Int32.Parse(FieldID), DataTypeID); } break; case 3: //TextArea CreateCompareDropDownList(i, Int32.Parse(FieldID), DataTypeID); GPRP.GPRPControls.TextBox txtAreaField = new GPRP.GPRPControls.TextBox(); txtAreaField.ID = "field" + FieldID; txtAreaField.TextMode = TextBoxMode.MultiLine; txtAreaField.Width = new Unit(FieldTextLength); txtAreaField.Rows = FieldTextHeight; txtAreaField.Text = FieldDefaultValue; txtAreaField.Attributes.Add("onkeydown", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(txtAreaField); break; case 4: //checkboxList CreateCompareDropDownList(i, Int32.Parse(FieldID), DataTypeID); GPRP.GPRPControls.CheckBoxList chkLstField = new GPRP.GPRPControls.CheckBoxList(); chkLstField.RepeatDirection = RepeatDirection.Horizontal; chkLstField.ID = "field" + FieldID; chkLstField.RepeatColumns = 6; //获得数据源 DataTable dtList = DbHelper.GetInstance().GetMultiSelectDataSource(Convert.ToInt32(FieldID), IsDynamic, DataSetID, ValueColumn, TextColumn); chkLstField.AddTableData(dtList); chkLstField.DataTextField = TextColumn; chkLstField.DataValueField = ValueColumn; chkLstField.Attributes.Add("onclick", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(chkLstField); break; case 5: // dropdownlist CreateCompareDropDownList(i, Int32.Parse(FieldID), DataTypeID); GPRP.GPRPControls.DropDownList ddlField = new GPRP.GPRPControls.DropDownList(); ddlField.ID = "field" + FieldID; ddlField.Width = new Unit(120); DataTable dtDrop = DbHelper.GetInstance().GetMultiSelectDataSource(Convert.ToInt32(FieldID), IsDynamic, DataSetID, ValueColumn, TextColumn); ddlField.AddTableData(dtDrop); ddlField.DataTextField = TextColumn; ddlField.DataValueField = ValueColumn; ddlField.SelectedValue = FieldDefaultValue; ddlField.Attributes.Add("onfocus", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(ddlField); break; case 6: //checkbox,不用加比较符下拉框 System.Web.UI.WebControls.CheckBox chkField = new System.Web.UI.WebControls.CheckBox(); chkField.ID = "field" + FieldID; chkField.Checked = false; chkField.Attributes.Add("onfocus", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(chkField); break; case 7: //uploadFile break; case 8: //浏览形式按钮 CreateCompareDropDownList(i, Int32.Parse(FieldID), DataTypeID); string BrowsePage = dtMainField.Rows[i]["BrowsePage"].ToString(); string BrowseTypeName = dtMainField.Rows[i]["BrowseTypeName"].ToString(); GPRP.GPRPControls.TextBox txtBrowseField = new GPRP.GPRPControls.TextBox(); txtBrowseField.ID = "fieldText" + FieldID; txtBrowseField.Width = new Unit(120); System.Web.UI.WebControls.HiddenField txtBrowseFieldValue = new System.Web.UI.WebControls.HiddenField(); txtBrowseFieldValue.ID = "field" + FieldID; txtBrowseField.AddAttributes("readonly", "true"); // txtBrowseField.Attributes.Add("ontextchanged", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(txtBrowseField); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(txtBrowseFieldValue); ImageButton imageButton = new ImageButton(); imageButton.ID = "fieldImage" + FieldID; imageButton.ImageAlign = ImageAlign.Middle; imageButton.ToolTip = "搜索"; imageButton.ImageUrl = "../images/arrow_black.gif"; imageButton.OnClientClick = "return btnBrowseFieldClick('" + txtBrowseField.ID + "','" + txtBrowseFieldValue.ID + "','" + BrowsePage + "','" + BrowseTypeName + "');"; imageButton.Attributes.Add("onfocus", "javascript:cbConditionChecked('" + ((CheckBox)GridView1.Rows[i].FindControl("cbCondition")).ClientID + "')"); ((PlaceHolder)GridView1.Rows[i].FindControl("placeHolder")).Controls.Add(imageButton); break; } } }