Exemple #1
0
        /// <summary>
        /// 取得label对应的xml
        /// </summary>
        /// <param name="item">blockfielditem</param>
        /// <returns>xml</returns>
        private string GetLabelXml(TBlockFieldItem item, String tableName, ref String id)
        {
            String strLabel = String.Empty;
            if (string.Compare(item.ControlType, "refvalbox", true) == 0)
            {
                WebControl control = null;
                PropertyInfo info = null;
                if (!string.IsNullOrEmpty(item.RefValNo) || (item.RefField != null))
                {
                    control = new WebRefVal();
                    control.ID = string.Format("{0}RefVal", item.DataField);
                    (control as WebRefVal).DataSourceID = GenWebDataSource(item, tableName, "RefVal", string.Empty);
                    (control as WebRefVal).DataBindingField = item.DataField;
                    (control as WebRefVal).DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                    (control as WebRefVal).DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                    (control as WebRefVal).BackColor = System.Drawing.Color.Transparent;
                    (control as WebRefVal).BorderStyle = BorderStyle.None;
                    (control as WebRefVal).ReadOnly = true;
                    (control as WebRefVal).Width = 100;
                    info = control.GetType().GetProperty("BindingValue");
                    //id = control.ID;
                    strLabel = GetControlXml(control, info, item.DataField, item.EditMask);
                }
                else
                {
                    control = new Label();
                    control.ID = string.Format("{0}Label", item.DataField);
                    strLabel = GetControlXml(control, control.GetType().GetProperty("Text"), item.DataField, item.EditMask);
                }
                //control.ID = string.Format("{0}{1}", control.ID, id);

                int i = strLabel.IndexOf("runat=\"server\"");
                strLabel = strLabel.Insert(i + 14, " Width=\"100\" BackColor=\"Transparent\"");
            }
            else
            {
                //用上面的方法实现
                Label label = new Label();
                label.ID = string.Format("{0}Label", item.DataField);
                strLabel = GetControlXml(label, label.GetType().GetProperty("Text"), item.DataField, item.EditMask);
            }
            return strLabel;
        }
Exemple #2
0
        private string GetLabelXml(DataRow dr)
        {
            String strLabel = String.Empty;

            //用上面的方法实现
            System.Web.UI.WebControls.Label label = new System.Web.UI.WebControls.Label();
            label.ID = string.Format("{0}Label", dr["ColumnName"].ToString());
            strLabel = GetControlXml(label, label.GetType().GetProperty("Text"), dr["ColumnName"].ToString(), dr["EditMask"].ToString());
            return strLabel;
        }