Exemple #1
0
        /// <summary>
        /// 刷新formview的内容
        /// </summary>
        /// <param name="formViewElement">formview的结构</param>
        /// <param name="blockItem">blockItem</param>
        private void RefreshFormView(WebDevPage.IHTMLElement formViewElement, TBlockItem blockItem)
        {
            if (formViewElement != null)
            {
                StringBuilder builderEditTemplate = new StringBuilder("<EditItemTemplate>\r\n\t<table class=\"container_table\">");
                StringBuilder builderInsertTemplate = new StringBuilder("<InsertItemTemplate>\r\n\t<table class=\"container_table\">");
                StringBuilder builderItemTemplate = new StringBuilder("<ItemTemplate>\r\n\t<table class=\"container_table\">");
                FormViewFieldsCollection fields = new FormViewFieldsCollection(null, typeof(FormViewField));
                int layoutcolnum = int.Parse(formViewElement.getAttribute("LayOutColNum", 0).ToString());
                for (int i = 0; i < blockItem.BlockFieldItems.Count; i++)
                {
                    TBlockFieldItem item = (TBlockFieldItem)blockItem.BlockFieldItems[i];
                    string controlid = string.Empty;
                    if (i % layoutcolnum == 0 || layoutcolnum == 1)
                    {
                        builderEditTemplate.AppendLine("\t\t<tr>");
                        builderInsertTemplate.AppendLine("\t\t<tr>");
                        builderItemTemplate.AppendLine("\t\t<tr>");
                    }
                    builderEditTemplate.AppendLine("\t\t\t<td class=\"caption_td\">");
                    builderEditTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetCaptionLabelXml(item, true)));
                    builderEditTemplate.AppendLine("\t\t\t</td>");
                    builderEditTemplate.AppendLine("\t\t\t<td class=\"value_td\">");
                    controlid = "E";
                    builderEditTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetControlXml(item, blockItem.TableName, ref controlid)));
                    builderEditTemplate.AppendLine("\t\t\t</td>");

                    builderInsertTemplate.AppendLine("\t\t\t<td class=\"caption_td\">");
                    builderInsertTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetCaptionLabelXml(item, true)));
                    builderInsertTemplate.AppendLine("\t\t\t</td>");
                    builderInsertTemplate.AppendLine("\t\t\t<td class=\"value_td\">");
                    controlid = "I";
                    builderInsertTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetControlXml(item, blockItem.TableName, ref controlid)));
                    builderInsertTemplate.AppendLine("\t\t\t</td>");

                    builderItemTemplate.AppendLine("\t\t\t<td class=\"caption_td\">");
                    builderItemTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetCaptionLabelXml(item, false)));
                    builderItemTemplate.AppendLine("\t\t\t</td>");

                    builderItemTemplate.AppendLine("\t\t\t<td class=\"value_td\">");
                    builderItemTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetLabelXml(item, blockItem.TableName, ref controlid)));
                    builderItemTemplate.AppendLine("\t\t\t</td>");
                    if (i % layoutcolnum == layoutcolnum - 1 || layoutcolnum == 1 || i == blockItem.BlockFieldItems.Count - 1)
                    {
                        builderEditTemplate.AppendLine("\t\t</tr>");
                        builderInsertTemplate.AppendLine("\t\t</tr>");
                        builderItemTemplate.AppendLine("\t\t</tr>");
                    }

                    FormViewField field = new FormViewField();
                    field.FieldName = item.DataField;
                    field.ControlID = controlid;
                    fields.Add(field);
                }
                builderEditTemplate.AppendLine("\t</table>\r\n</EditItemTemplate>");
                builderInsertTemplate.AppendLine("\t</table>\r\n</InsertItemTemplate>");
                builderItemTemplate.AppendLine("\t</table>\r\n</ItemTemplate>");

                SetCollectionValue(formViewElement, typeof(WebFormView).GetProperty("Fields"), fields);
                SetTemplateValue(formViewElement, builderItemTemplate.ToString(), "ItemTemplate");
                SetTemplateValue(formViewElement, builderInsertTemplate.ToString(), "InsertItemTemplate");
                SetTemplateValue(formViewElement, builderEditTemplate.ToString(), "EditItemTemplate");
            }
        }
Exemple #2
0
        private void RefreshFormView(WebDevPage.IHTMLElement formViewElement, DataRowCollection drc)
        {
            if (formViewElement != null)
            {
                StringBuilder builderItemTemplate = new StringBuilder("<ItemTemplate>\r\n\t<table class=\"container_table\">");
                FormViewFieldsCollection fields = new FormViewFieldsCollection(null, typeof(FormViewField));
                int layoutcolnum = int.Parse(formViewElement.getAttribute("LayOutColNum", 0).ToString());
                for (int i = 0; i < SelectedMasterFields.Rows.Count; i++)
                {
                    string controlid = string.Empty;
                    if (i % layoutcolnum == 0 || layoutcolnum == 1)
                    {
                        builderItemTemplate.AppendLine("\t\t<tr>");
                    }

                    builderItemTemplate.AppendLine("\t\t\t<td>");
                    builderItemTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetCaptionLabelXml(SelectedMasterFields.Rows[i], false)));
                    builderItemTemplate.AppendLine("\t\t\t</td>");

                    builderItemTemplate.AppendLine("\t\t\t<td>");
                    builderItemTemplate.AppendLine(string.Format("\t\t\t\t{0}", GetLabelXml(SelectedMasterFields.Rows[i])));
                    builderItemTemplate.AppendLine("\t\t\t</td>");
                    if (i % layoutcolnum == layoutcolnum - 1 || layoutcolnum == 1 || i == SelectedMasterFields.Rows.Count - 1)
                    {
                        builderItemTemplate.AppendLine("\t\t</tr>");
                    }

                    FormViewField field = new FormViewField();
                    field.FieldName = SelectedMasterFields.Rows[i]["ColumnName"].ToString();
                    field.ControlID = controlid;
                    fields.Add(field);
                }
                builderItemTemplate.AppendLine("\t</table>\r\n</ItemTemplate>");

            SetCollectionValue(formViewElement, typeof(WebFormView).GetProperty("Fields"), fields);
                SetTemplateValue(formViewElement, builderItemTemplate.ToString(), "ItemTemplate");
            }
        }