Unable to get to the CheckboxGroup value

  1. #1

    Unable to get to the CheckboxGroup value

    TestAddShopInfo.ascx:
    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel16"
                        Layout="Column">
                        <Items>
                            <ext:CheckboxGroup ID="cblBusinessDistrict" runat="server">
                            </ext:CheckboxGroup>
                        </Items>
                    </ext:FormPanel>
     <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel17"
                        Layout="Column">
                        <Items>
                            <ext:RadioGroup runat="server" Width="280px" ID="rblDetectorState">
                            </ext:RadioGroup>
                            <ext:DisplayField runat="server" ID="DisplayField25" Text="(&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField LabelWidth="80" ID="txtInstallationValidity" Width="180" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField24" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField LabelWidth="80" ID="txtLastDecorationDate" Width="180" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField26" Text="&nbsp;)">
                            </ext:DisplayField>
                        </Items>
                    </ext:FormPanel>
    <ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
                <DirectEvents>
                    <Click OnEvent="btnSave_Click">
                        <EventMask ShowMask="true"  />
                    </Click>
                </DirectEvents>
            </ext:Button>
    CS Page_Load :
    BindCheckGroup(shopInfo.IlBusinessDistrict as List<BusinessDistrict>, "cblBusinessDistrict", "BDTypeName", "BDTypeId", "CheckValue");

      protected void BindCheckGroup<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string CheckedPropertyName)
        {
            
            if (lst != null && lst.Count > 0)
            {
                CheckboxGroup groupChks = this.FindControl(ID) as Ext.Net.CheckboxGroup;
                if (groupChks == null)
                    return;
                groupChks.ColumnsNumber = 4;
                groupChks.Items.Clear();
                foreach (var item in lst)
                {
                    T t = item;
                    Type type = t.GetType();
                    Ext.Net.Checkbox chk = new Ext.Net.Checkbox();
                    PropertyInfo TextProInfo = type.GetProperty(TextPropertyName);
                    if (TextProInfo == null)
                        ThrowNullException(type, TextPropertyName);
                    PropertyInfo ValueProInfo = type.GetProperty(ValuePropertyName);
                    if (ValueProInfo == null)
                        ThrowNullException(type, ValuePropertyName);
                    PropertyInfo CheckedProInfo = type.GetProperty(CheckedPropertyName);
                    if (CheckedProInfo == null)
                        ThrowNullException(type, CheckedPropertyName);
                    object objText = TextProInfo.GetValue(t, null);
                    chk.BoxLabel = objText == null ? string.Empty : objText.ToString();
                    object objValue = ValueProInfo.GetValue(t, null).ToString();
                    chk.Tag = objValue == null ? string.Empty : objValue.ToString();
                    if (CheckedProInfo.GetValue(t, null).ToString() == "1")
                        chk.Checked = true;
                    groupChks.Items.Add(chk);
                }
            }
        }
    btnSave_Click:
    List<BusinessDistrict> lstBusinessDistrict = new List<BusinessDistrict>();
            Dictionary<string, string> dicBusinessDistrictFields = new Dictionary<string, string>();
            dicBusinessDistrictFields.Add("BDId", "NewGuid()");
            dicBusinessDistrictFields.Add("ShopId", ShopID);
            SetValueFromCheckGroup(lstBusinessDistrict, "cblBusinessDistrict", "BDTypeName", "BDTypeId", "CheckValue", "NBShopMode.Shop.BusinessDistrict", dicBusinessDistrictFields);
        protected List<T> SetValueFromCheckGroup<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string CheckedPropertyName, string _className, Dictionary<string, string> _dicFields)
        {
            #region 绑定商圈类型列表
            CheckboxGroup groupChks = this.FindControl(ID) as Ext.Net.CheckboxGroup;
            if (groupChks == null)
                return null;
            //反射加载NBShopMode程序集
            Assembly _assembly = Assembly.Load("NBShopMode");
            foreach (var item in groupChks.Items)
            {
                Ext.Net.Checkbox chk = item as Ext.Net.Checkbox;
                if (chk != null)
                {
                    //通过反射创建该类的实例
                    T _t = (T)_assembly.CreateInstance(_className, true);
                    //获取类型
                    Type _type = _t.GetType();
                    if (_type == null)
                        return null;
    
                    //获取文本属性
                    PropertyInfo TextProInfo = _type.GetProperty(TextPropertyName);
                    if (TextProInfo == null)
                        ThrowNullException(_type, TextPropertyName);
                    //获取值属性
                    PropertyInfo ValueProInfo = _type.GetProperty(ValuePropertyName);
                    if (ValueProInfo == null)
                        ThrowNullException(_type, ValuePropertyName);
                    //获取选择属性
                    PropertyInfo CheckedProInfo = _type.GetProperty(CheckedPropertyName);
                    if (CheckedProInfo == null)
                        ThrowNullException(_type, CheckedPropertyName);
                    //设置文本属性的值
                    if (!string.IsNullOrEmpty(chk.BoxLabel))
                        TextProInfo.SetValue(_t, Convert.ChangeType(chk.BoxLabel, TextProInfo.PropertyType), null);
                    //设置值属性的值
                    if (!string.IsNullOrEmpty(chk.Tag))
                        ValueProInfo.SetValue(_t, Convert.ChangeType(chk.Tag, ValueProInfo.PropertyType), null);
                    //设置选择属性的值(1表示选择,0表示未选择)
                    if (chk.Checked)
                        CheckedProInfo.SetValue(_t, Convert.ChangeType(1, CheckedProInfo.PropertyType), null);
                    else
                        CheckedProInfo.SetValue(_t, Convert.ChangeType(0, CheckedProInfo.PropertyType), null);
    
                    //如果扩展字段不为空
                    if (_dicFields != null && _dicFields.Count >= 0)
                    {
                        foreach (var _key in _dicFields.Keys)
                        {
                            PropertyInfo _pro = _type.GetProperty(_key);
                            if (_dicFields[_key] == "NewGuid()")
                                _pro.SetValue(_t, Convert.ChangeType(Guid.NewGuid().ToString().Replace("-", "").ToUpper(), _pro.PropertyType), null);
                            else
                                _pro.SetValue(_t, Convert.ChangeType(_dicFields[_key], _pro.PropertyType), null);
                        }
                    }
                    lst.Add(_t);
                }
            }
            return lst;
            #endregion
        }
    Unable to get to the CheckboxGroup Check value When I click save button
    Last edited by Daniil; Feb 24, 2011 at 9:43 PM. Reason: Please use [CODE] tags for all code
  2. #2
    Hi,

    I can't see the problem without reproducing the problem.

    Please provide a full (but simplified) sample to reproduce.

    Please see how it can look:
    Forum Guidelines For Posting New Topics
  3. #3

    This is the all source

    Thank you!This is all source.I put it replaced with CheckBoxList or RadioButtonList,But still won't do.If there is no way,I will use js to realize.
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestAddShopInfo.ascx.cs"
        Inherits="UserControls_TestAddShopInfo" EnableViewState="true" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:ResourceManager ID="ResourceManager1" runat="server">
    </ext:ResourceManager>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <style type="text/css">
        .labelStyle
        {
            color: #444;
            font-size: 11px;
            background-color: #e7f0f6;
        }
        label
        {
            color: #444;
            font-size: 12px;
        }
    </style>
    <ext:FormPanel ID="FormPanel1" Collapsible="true" Header="false" Icon="PageAdd" runat="server"
        Title="添加新概念店" MonitorValid="true" Padding="5" ButtonAlign="Right" Width="830px"
        Layout="Form">
        <Items>
            <ext:FormPanel Header="true" Icon="UserAdd" ID="fpnlShopkeeper" Border="true" Collapsible="true"
                runat="server" Title="店主信息" AutoHeight="true" LabelWidth="120">
                <Content>
                    <ext:FormPanel runat="server" Border="false" PaddingSummary="0" ID="FormPanel11"
                        Layout="Column">
                        <Items>
                            <ext:ComboBox Editable="false" ID="ddlTypeOfIdentificationDocument" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="df" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtIDNO" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField4" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtName" runat="server">
                            </ext:TextField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" Border="false" PaddingSummary="0" ID="FormPanel2" Layout="Column">
                        <Items>
                            <ext:TextField ID="txtNationality" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField2" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlMaritalStatus" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField3" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtHighestEducation" runat="server">
                            </ext:TextField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel3" Layout="Column">
                        <Items>
                            <ext:ComboBox ID="ddlSex" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField1" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField ID="txtBirthday" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField5" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtQQ" runat="server">
                            </ext:TextField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel4" Layout="Column">
                        <Items>
                            <ext:TextField ID="txtHomePhone" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField6" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtMobilePhone" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField7" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtEmail" runat="server">
                            </ext:TextField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel5" Layout="Column">
                        <Items>
                            <ext:NumberField ID="txtShopCount" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField8" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField ID="txtOpeningTime" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField9" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                        </Items>
                    </ext:FormPanel>
                </Content>
            </ext:FormPanel>
            <ext:FormPanel ID="fpnlShopInfo" Icon="PhoneAdd" Border="true" Collapsible="true"
                runat="server" Title="门店信息" AutoHeight="true" LabelWidth="120">
                <Content>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel7" Layout="Column">
                        <Items>
                            <ext:ComboBox ID="ddlArea" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField10" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlProvince" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField11" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlCitys" Editable="false" runat="server">
                            </ext:ComboBox>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel8" Layout="Column">
                        <Items>
                            <ext:TextField ID="txtShopName" IsRemoteValidation="true" runat="server">
                                <RemoteValidation OnValidation="CheckField">
                                </RemoteValidation>
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField13" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtShopPhone" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField12" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlShopType" Editable="false" runat="server">
                            </ext:ComboBox>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel9" Layout="Column">
                        <Items>
                            <ext:TextField ID="txtOracleNO" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField14" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtContractNO" runat="server">
                            </ext:TextField>
                            <ext:DisplayField runat="server" ID="DisplayField15" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:TextField ID="txtAddress" runat="server">
                            </ext:TextField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" Border="false" PaddingSummary="0" ID="fpnlAcreage"
                        Layout="Form">
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel12"
                        Layout="Column">
                        <Items>
                            <ext:ComboBox ID="ddlOwnerType" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField16" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlFrontageState" Editable="false" runat="server">
                            </ext:ComboBox>
                            <ext:DisplayField runat="server" ID="DisplayField17" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:ComboBox ID="ddlCrossroadsState" Editable="false" runat="server">
                            </ext:ComboBox>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel13"
                        Layout="Column">
                        <Items>
                            <ext:NumberField ID="txtFloor" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField18" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtFloorNum" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField19" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtSignboardAcreage" runat="server">
                            </ext:NumberField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel14"
                        Layout="Column">
                        <Items>
                            <ext:NumberField ID="txtEmployeeNum" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField20" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtTechnicianNum" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField21" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtCustomerNum" runat="server">
                            </ext:NumberField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel15"
                        Layout="Column">
                        <Items>
                            <ext:NumberField ID="txtRoomNum" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField22" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtBedNum" runat="server">
                            </ext:NumberField>
                            <ext:DisplayField runat="server" ID="DisplayField23" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:NumberField ID="txtMonthlySales" runat="server">
                            </ext:NumberField>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel16"
                        Layout="Column">
                        <Items>
                            <ext:FormPanel ID="Panel1" IsFormField="true" FieldLabel="商店圈" runat="server" Border="false"
                                Width="820" Height="40">
                                <Content>
                                    <asp:CheckBoxList ID="cblBusinessDistrict" runat="server">
                                    </asp:CheckBoxList>
                                </Content>
                            </ext:FormPanel>
                            <%-- <ext:CheckboxGroup ID="cblBusinessDistrict" runat="server">
                            </ext:CheckboxGroup>--%>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel17"
                        Layout="Column">
                        <Items>
                            <ext:FormPanel ID="FormPanel6" IsFormField="true" FieldLabel="十大功能检测仪" runat="server"
                                Border="false" Width="250" Height="50">
                                <Content>
                                    <asp:RadioButtonList ID="rblDetectorState" RepeatLayout="Table" Width="120" runat="server"></asp:RadioButtonList>
                                </Content>
                            </ext:FormPanel>
                            <%--<ext:RadioGroup runat="server" Width="280px" ID="rblDetectorState">
                            </ext:RadioGroup>--%>
                            <ext:DisplayField runat="server" ID="DisplayField25" Text="(&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField LabelWidth="80" ID="txtInstallationValidity" Width="180" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField24" Text="&nbsp;&nbsp;">
                            </ext:DisplayField>
                            <ext:DateField LabelWidth="80" ID="txtLastDecorationDate" Width="180" runat="server">
                            </ext:DateField>
                            <ext:DisplayField runat="server" ID="DisplayField26" Text="&nbsp;)">
                            </ext:DisplayField>
                        </Items>
                    </ext:FormPanel>
                </Content>
            </ext:FormPanel>
            <ext:FormPanel ID="FormPanel19" Icon="ApplicationCascade" Border="true" Collapsible="true"
                runat="server" Title="竞争环境" AutoHeight="true" LabelWidth="120">
                <Content>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel20"
                        Layout="Column">
                        <Items>
                            <ext:FormPanel runat="server" IsFormField="true" FieldLabel="临近竞争店" Border="false"
                                Width="820" Height="40">
                                <Content>
                                    <asp:CheckBoxList ID="cblCompeteShops" runat="server">
                                    </asp:CheckBoxList>
                                </Content>
                            </ext:FormPanel>
                            <%-- <ext:CheckboxGroup ID="cblCompeteShops" runat="server">
                            </ext:CheckboxGroup>--%>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel21"
                        Layout="Column">
                        <Items>
                            <ext:TextArea ID="txtCompeteRemark" Width="600" Height="100" runat="server">
                            </ext:TextArea>
                        </Items>
                    </ext:FormPanel>
                </Content>
            </ext:FormPanel>
            <ext:FormPanel ID="FormPanel10" Icon="ApplicationAdd" Border="true" Collapsible="true"
                runat="server" Title="硬件配套" AutoHeight="true" LabelWidth="120">
                <Content>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel18"
                        Layout="Column" Height="80">
                        <%--<Items>
                            <ext:CheckboxGroup ID="cblHardwares" runat="server">
                            </ext:CheckboxGroup>
                        </Items>--%>
                        <Content>
                            <asp:CheckBoxList ID="cblHardwares" runat="server">
                            </asp:CheckBoxList>
                        </Content>
                    </ext:FormPanel>
                </Content>
            </ext:FormPanel>
            <ext:FormPanel ID="FormPanel22" Icon="UserComment" Border="true" Collapsible="true"
                runat="server" Title="需求建议" AutoHeight="true" LabelWidth="120">
                <Content>
                    <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel23"
                        Layout="Column">
                        <Items>
                            <ext:TextArea ID="txtRemark" MaxLength="10" Width="600" Height="100" runat="server">
                            </ext:TextArea>
                        </Items>
                    </ext:FormPanel>
                </Content>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button ID="btnSave" runat="server" Text="保存" Icon="Disk">
                <DirectEvents>
                    <Click OnEvent="btnSave_Click">
                        <EventMask ShowMask="true" Msg="正在处理..." />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="Button2" runat="server" Text="提交" Icon="PageAdd" />
        </Buttons>
        <BottomBar>
            <ext:StatusBar ID="StatusBar1" runat="server" />
        </BottomBar>
        <TopBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                    <ext:Button ID="tbSave" runat="server" Icon="Disk" Text="保存">
                        <DirectEvents>
                            <Click OnEvent="btnSave_Click">
                                <EventMask ShowMask="true" Msg="正在处理数据..." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnSaveRecord" runat="server" Icon="PageAdd" Text="提交">
                        <DirectEvents>
                            <%-- <Click OnEvent="SaveClick" Before="return #{FormPanel1}.getForm().isValid();" Success="Ext.Msg.alert('', 'Saved');">
                                <ExtraParams>
                                    <ext:Parameter Name="recordId" Value="#{Store1}.getAt(0).id" Mode="Raw" />
                                </ExtraParams>
                            </Click>--%>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <Listeners>
            <ClientValidation Handler="#{btnSave}.setDisabled(!valid);#{tbSave}.setDisabled(!valid);this.getBottomToolbar().setStatus({text : valid ? '验证通过,可以提交数据' : '表单验证未通过,您不能提交数据', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
        </Listeners>
    </ext:FormPanel>
    <script type="text/javascript">
        Ext.onReady(function () {
            setLabelClass();
        });
        function setLabelClass() {
            $(".x-form-item-label").addClass("labelStyle");
        }
    </script>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Xml.Linq;
    using Ext.Net;
    using NBShopMode.Shop;
    using NBShopService;
    using System.Reflection;
    using System.Text;
    public partial class UserControls_TestAddShopInfo : System.Web.UI.UserControl
    {
        NBShopService.AttributesServices attributes = new NBShopService.AttributesServices();
        ShopService shopServices = new ShopService();
        protected void Page_Load(object sender, EventArgs e)
        {
            Loading();
        }
    
        private void Loading()
        {
            string xmlPath = Server.MapPath("~/App_Data/AddShopperFileds.xml");
            ShopID = shopServices.GetNewGuid();
            ShopInfo shopInfo = shopServices.SelectAllShopInfoByShopId(ShopID);
            ShopkeeperID = shopInfo.Shopkeeper.Id;
            try
            {
                //默认宽度
                int _width = 200;
                //默认验证提示模式
                string _msgTarget = null;
    
                if (File.Exists(xmlPath))
                {
                    XElement elements = XElement.Load(xmlPath);
                    var fields = elements.Descendants("Field");
                    var GlobalDefaultConfig = elements.Element("GlobalDefaultConfig");
                    var attrDefaultWidth = GlobalDefaultConfig.Element("Width");
                    if (attrDefaultWidth != null && MyRegex.IsNumberRegex(attrDefaultWidth.Value))
                        _width = Convert.ToInt32(attrDefaultWidth.Value);
                    var defaultMsgTarget = GlobalDefaultConfig.Element("MsgTarget");
                    if (defaultMsgTarget != null)
                        _msgTarget = defaultMsgTarget.Value;
    
                    if (!IsPostBack)
                    {
                        SetFields(_width, _msgTarget, fields);
                        #region 绑定属性(性别、十字路口等等)
                        #region 绑定性别
                        BindComobox(shopServices.SelectSexKind() as List<NBShopMode.Attributes.SysAttribute>, "ddlSex", "AttributeValue", "AttributeId", shopInfo.Shopkeeper.SexTypeId);
                        #endregion
                        #region 十字路口
                        BindComobox(shopServices.SelectCrossroadsStatus() as List<NBShopMode.Attributes.SysAttribute>, "ddlCrossroadsState", "AttributeValue", "AttributeId", shopInfo.Shop.CrossroadsStatusValue);
                        #endregion
                        #region 临街状态
                        BindComobox(shopServices.SelectFrontageStatus() as List<NBShopMode.Attributes.SysAttribute>, "ddlFrontageState", "AttributeValue", "AttributeId", shopInfo.Shop.FrontageStatusValue);
                        #endregion
                        #region 婚姻状态
                        BindComobox(shopServices.SelectMaritalStatus() as List<NBShopMode.Attributes.SysAttribute>, "ddlMaritalStatus", "AttributeValue", "AttributeId", shopInfo.Shopkeeper.MaritalStatus);
                        #endregion
                        #region 店铺持有类型
                        BindComobox(shopServices.SelectShopHoldKind() as List<NBShopMode.Attributes.SysAttribute>, "ddlOwnerType", "AttributeValue", "AttributeId", shopInfo.Shop.HoldStatusValue);
                        #endregion
                        #region 店铺类型
                        BindComobox(shopServices.SelectShopKind() as List<NBShopMode.Attributes.SysAttribute>, "ddlShopType", "AttributeValue", "AttributeId", shopInfo.Shop.ShopTypeValue);
                        #endregion
                        #region 证件类型
                        BindComobox(shopServices.SelectCredentialsKind() as List<NBShopMode.Attributes.SysAttribute>, "ddlTypeOfIdentificationDocument", "AttributeValue", "AttributeId", shopInfo.Shopkeeper.CredentialsName);
                        #endregion
                        #endregion
                    }
                    #region 绑定商店圈、临近竞争店、硬件设备等信息
                    BindCheckGroup(shopInfo.IlBusinessDistrict as List<BusinessDistrict>, "cblBusinessDistrict", "BDTypeName", "BDTypeId", "CheckValue");
                    BindCheckGroup(shopInfo.IlCompete as List<Compete>, "cblCompeteShops", "CompeteShopName", "CompeteShopId", "CheckValue");
                    BindCheckGroup(shopInfo.IlSupportingFacility as List<SupportingFacility>, "cblHardwares", "SFTypeName", "SFTypeId", "CheckValue");
                    BindRadioGroup(shopServices.SelectCheckMeterStatus() as List<NBShopMode.Attributes.SysAttribute>, "rblDetectorState", "AttributeValue", "AttributeId", shopInfo.Shop.CheckMeterStatusValue, false);
                    #endregion
                    #region 绑定面积信息
                    List<Acreage> lstAcreage = shopInfo.IlAcreage as List<Acreage>;
                    int i = 0;
                    foreach (var item in lstAcreage)
                    {
                        Ext.Net.FormPanel _fp = new FormPanel();
                        _fp.PaddingSummary = "0";
                        _fp.Border = false;
                        _fp.Layout = "Column";
                        Ext.Net.NumberField _nf1 = new NumberField();
                        _nf1.FieldLabel = item.AcreageTypeName + "(M²)";
                        _nf1.MinValue = 0;
                        _nf1.Text = Math.Round(item.AcreageValue, 2).ToString();
                        _nf1.Width = 250;
                        _nf1.LabelWidth = 120;
                        _nf1.ID = "Acreage" + i;
                        _fp.Items.Add(_nf1);
    
                        Ext.Net.DisplayField _df = new DisplayField();
                        _df.Text = "(&nbsp;";
                        _fp.Items.Add(_df);
    
                        Ext.Net.NumberField _nf2 = new NumberField();
                        _nf2.FieldLabel = "长(M)";
                        _nf2.LabelWidth = 75;
                        _nf2.MinValue = 0;
                        _nf2.Text = Math.Round(item.Length, 2).ToString();
                        _nf2.Width = 160;
                        _nf2.ID = "AcreageLength" + i;
                        _fp.Items.Add(_nf2);
    
                        Ext.Net.NumberField _nf3 = new NumberField();
                        _nf3.FieldLabel = "&nbsp;&nbsp;宽(M)";
                        _nf3.MinValue = 0;
                        _nf3.LabelWidth = 75;
                        _nf3.Text = Math.Round(item.Wide, 2).ToString();
                        _nf3.Width = 160;
                        _nf3.ID = "AcreageWide" + i;
                        _fp.Items.Add(_nf3);
    
                        Ext.Net.NumberField _nf4 = new NumberField();
                        _nf4.FieldLabel = "&nbsp;&nbsp;高(M)";
                        _nf4.MinValue = 0;
                        _nf4.LabelWidth = 75;
                        _nf4.Text = Math.Round(item.High, 2).ToString();
                        _nf4.Width = 160;
                        _nf4.ID = "AcreageHigh" + i;
                        _fp.Items.Add(_nf4);
    
                        Ext.Net.DisplayField _df2 = new DisplayField();
                        _df2.Text = "&nbsp;)";
                        _fp.Items.Add(_df2);
    
                        Ext.Net.Hidden _hdAcreageTypeId = new Hidden();
                        _hdAcreageTypeId.Value = item.AcreageTypeId;
                        _hdAcreageTypeId.ID = "AcreageTypeId" + i;
                        _fp.Items.Add(_hdAcreageTypeId);
    
                        fpnlAcreage.Items.Add(_fp);
    
                        i++;
                    }
                    #endregion
                    GC.Collect();
                }
    
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                //LogManager.WriteErrorLog(ex);
            }
        }
    
        protected void CheckField(object sender, RemoteValidationEventArgs e)
        {
            TextField field = (TextField)sender;
            if (field.Text.Length > 0)
            {
                if (field.Text.Contains("测试"))
                {
                    e.Success = false;
                    e.ErrorMessage = "该项已存在,请不要重复添加!";
                }
                else
                {
                    e.Success = true;
                }
            }
            else
            {
                e.Success = false;
                e.ErrorMessage = "请填写店名!";
            }
        }
    
        /// <summary>
        /// 绑定复选框组
        /// </summary>
        /// <typeparam name="T">类类型</typeparam>
        /// <param name="lst">泛型集合</param>
        /// <param name="ID">复选框组ID</param>
        /// <param name="TextPropertyName">需要绑定的文本属性字段名(大写小都必须一致)</param>
        /// <param name="ValuePropertyName">需要绑定的值属性字段名(大写小都必须一致)</param>
        /// <param name="CheckedPropertyName">需要绑定的选择属性字段名(大写小都必须一致)</param>
        protected void BindCheckGroup<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string CheckedPropertyName)
        {
            #region 绑定商圈类型列表
            if (lst != null && lst.Count > 0)
            {
                Control _control = this.FindControl(ID);
                if (_control is Ext.Net.CheckboxGroup)
                {
                    CheckboxGroup groupChks = _control as Ext.Net.CheckboxGroup;
                    if (groupChks == null)
                        return;
                    groupChks.ColumnsNumber = 4;
                    groupChks.Items.Clear();
                    foreach (var item in lst)
                    {
                        T t = item;
                        Type type = t.GetType();
                        Ext.Net.Checkbox chk = new Ext.Net.Checkbox();
                        PropertyInfo TextProInfo = type.GetProperty(TextPropertyName);
                        if (TextProInfo == null)
                            ThrowNullException(type, TextPropertyName);
                        PropertyInfo ValueProInfo = type.GetProperty(ValuePropertyName);
                        if (ValueProInfo == null)
                            ThrowNullException(type, ValuePropertyName);
                        PropertyInfo CheckedProInfo = type.GetProperty(CheckedPropertyName);
                        if (CheckedProInfo == null)
                            ThrowNullException(type, CheckedPropertyName);
                        object objText = TextProInfo.GetValue(t, null);
                        chk.BoxLabel = objText == null ? string.Empty : objText.ToString();
                        object objValue = ValueProInfo.GetValue(t, null).ToString();
                        chk.Tag = objValue == null ? string.Empty : objValue.ToString();
                        if (CheckedProInfo.GetValue(t, null).ToString() == "1")
                            chk.Checked = true;
                        groupChks.Items.Add(chk);
                    }
                }
                else if (_control is CheckBoxList)
                {
                    CheckBoxList _cbl = _control as CheckBoxList;
                    _cbl.RepeatDirection = RepeatDirection.Horizontal;
                    _cbl.RepeatLayout = RepeatLayout.Table;
                    _cbl.RepeatColumns = 7;
                    _cbl.Width = Unit.Parse("100%");
                    foreach (var item in lst)
                    {
                        T t = item;
                        Type type = t.GetType();
                        Ext.Net.Checkbox chk = new Ext.Net.Checkbox();
                        PropertyInfo TextProInfo = type.GetProperty(TextPropertyName);
                        if (TextProInfo == null)
                            ThrowNullException(type, TextPropertyName);
                        PropertyInfo ValueProInfo = type.GetProperty(ValuePropertyName);
                        if (ValueProInfo == null)
                            ThrowNullException(type, ValuePropertyName);
                        PropertyInfo CheckedProInfo = type.GetProperty(CheckedPropertyName);
                        if (CheckedProInfo == null)
                            ThrowNullException(type, CheckedPropertyName);
    
                        object objText = TextProInfo.GetValue(t, null);
                        object objValue = ValueProInfo.GetValue(t, null).ToString();
    
                        System.Web.UI.WebControls.ListItem _li = new System.Web.UI.WebControls.ListItem();
                        _li.Text = objText == null ? string.Empty : objText.ToString();
                        _li.Value = objValue == null ? string.Empty : objValue.ToString();
                        if (CheckedProInfo.GetValue(t, null).ToString() == "1")
                            _li.Selected = true;
                        _cbl.Items.Add(_li);
                    }
                }
    
            }
            #endregion
        }
    
        /// <summary>
        /// 通过反射绑定下拉列表
        /// </summary>
        /// <typeparam name="T">类类型</typeparam>
        /// <param name="lst">泛型集合</param>
        /// <param name="ID">下拉列表ID</param>
        /// <param name="TextPropertyName">文本属性名</param>
        /// <param name="ValuePropertyName">值属性名</param>
        /// <param name="_SelectValue">选择的值</param>
        protected void BindComobox<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string _SelectValue)
        {
            if (lst != null && lst.Count > 0)
            {
                ComboBox _cbos = this.FindControl(ID) as Ext.Net.ComboBox;
                if (_cbos == null)
                    return;
                _cbos.Items.Clear();
                foreach (var item in lst)
                {
                    T t = item;
                    Type type = t.GetType();
                    Ext.Net.ListItem _li = new Ext.Net.ListItem();
                    PropertyInfo TextProInfo = type.GetProperty(TextPropertyName);
                    if (TextProInfo == null)
                        ThrowNullException(type, TextPropertyName);
                    PropertyInfo ValueProInfo = type.GetProperty(ValuePropertyName);
                    if (ValueProInfo == null)
                        ThrowNullException(type, ValuePropertyName);
    
                    object objText = TextProInfo.GetValue(t, null);
                    _li.Text = objText == null ? string.Empty : objText.ToString();
                    object objValue = ValueProInfo.GetValue(t, null).ToString();
                    _li.Value = objValue == null ? string.Empty : objValue.ToString();
                    _cbos.Items.Add(_li);
                }
                if (!string.IsNullOrEmpty(_SelectValue))
                    _cbos.SelectByValue(_SelectValue);
            }
        }
        /// <summary>
        /// 反射设置选择框组的值
        /// </summary>
        /// <typeparam name="T">类类型</typeparam>
        /// <param name="lst">泛型集合</param>
        /// <param name="ID">控件服务器ID</param>
        /// <param name="TextPropertyName">文本属性名</param>
        /// <param name="ValuePropertyName">值属性名</param>
        /// <param name="CheckedPropertyName">选择框属性名</param>
        /// <param name="_className">类名</param>
        /// <param name="_dicFields">扩展字段集合</param>
        /// <returns>泛型集合(NewGuid()表示生成新的Guid)</returns>
        protected List<T> SetValueFromCheckGroup<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string CheckedPropertyName, string _className, Dictionary<string, string> _dicFields)
        {
    
            Control _control = this.FindControl(ID);
            if (_control == null)
            {
                return null;
            }
            if (_control is Ext.Net.CheckboxGroup)
            {
                #region ExtCheckGroupBox
                CheckboxGroup groupChks = _control as Ext.Net.CheckboxGroup;
                //反射加载NBShopMode程序集
                Assembly _assembly = Assembly.Load("NBShopMode");
                foreach (var item in groupChks.Items)
                {
                    Ext.Net.Checkbox chk = item as Ext.Net.Checkbox;
                    if (chk != null)
                    {
                        //通过反射创建该类的实例
                        T _t = (T)_assembly.CreateInstance(_className, true);
                        //获取类型
                        Type _type = _t.GetType();
                        if (_type == null)
                            return null;
    
                        //获取文本属性
                        PropertyInfo TextProInfo = _type.GetProperty(TextPropertyName);
                        if (TextProInfo == null)
                            ThrowNullException(_type, TextPropertyName);
                        //获取值属性
                        PropertyInfo ValueProInfo = _type.GetProperty(ValuePropertyName);
                        if (ValueProInfo == null)
                            ThrowNullException(_type, ValuePropertyName);
                        //获取选择属性
                        PropertyInfo CheckedProInfo = _type.GetProperty(CheckedPropertyName);
                        if (CheckedProInfo == null)
                            ThrowNullException(_type, CheckedPropertyName);
                        //设置文本属性的值
                        if (!string.IsNullOrEmpty(chk.BoxLabel))
                            TextProInfo.SetValue(_t, Convert.ChangeType(chk.BoxLabel, TextProInfo.PropertyType), null);
                        //设置值属性的值
                        if (!string.IsNullOrEmpty(chk.Tag))
                            ValueProInfo.SetValue(_t, Convert.ChangeType(chk.Tag, ValueProInfo.PropertyType), null);
                        //设置选择属性的值(1表示选择,0表示未选择)
                        if (chk.Checked)
                            CheckedProInfo.SetValue(_t, Convert.ChangeType(1, CheckedProInfo.PropertyType), null);
                        else
                            CheckedProInfo.SetValue(_t, Convert.ChangeType(0, CheckedProInfo.PropertyType), null);
    
                        //如果扩展字段不为空
                        if (_dicFields != null && _dicFields.Count >= 0)
                        {
                            foreach (var _key in _dicFields.Keys)
                            {
                                PropertyInfo _pro = _type.GetProperty(_key);
                                if (_dicFields[_key] == "NewGuid()")
                                    _pro.SetValue(_t, Convert.ChangeType(Guid.NewGuid().ToString().Replace("-", "").ToUpper(), _pro.PropertyType), null);
                                else
                                    _pro.SetValue(_t, Convert.ChangeType(_dicFields[_key], _pro.PropertyType), null);
                            }
                        }
                        lst.Add(_t);
                    }
                }
                return lst;
                #endregion
            }
            else if (_control is CheckBoxList)
            {
                #region CheckBoxList
                CheckBoxList groupChks = _control as CheckBoxList;
                //反射加载NBShopMode程序集
                Assembly _assembly = Assembly.Load("NBShopMode");
                foreach (System.Web.UI.WebControls.ListItem item in groupChks.Items)
                {
                    //通过反射创建该类的实例
                    T _t = (T)_assembly.CreateInstance(_className, true);
                    //获取类型
                    Type _type = _t.GetType();
                    if (_type == null)
                        return null;
    
                    //获取文本属性
                    PropertyInfo TextProInfo = _type.GetProperty(TextPropertyName);
                    if (TextProInfo == null)
                        ThrowNullException(_type, TextPropertyName);
                    //获取值属性
                    PropertyInfo ValueProInfo = _type.GetProperty(ValuePropertyName);
                    if (ValueProInfo == null)
                        ThrowNullException(_type, ValuePropertyName);
                    //获取选择属性
                    PropertyInfo CheckedProInfo = _type.GetProperty(CheckedPropertyName);
                    if (CheckedProInfo == null)
                        ThrowNullException(_type, CheckedPropertyName);
                    //设置文本属性的值
                    if (!string.IsNullOrEmpty(item.Text))
                        TextProInfo.SetValue(_t, Convert.ChangeType(item.Text, TextProInfo.PropertyType), null);
                    //设置值属性的值
                    if (!string.IsNullOrEmpty(item.Value))
                        ValueProInfo.SetValue(_t, Convert.ChangeType(item.Value, ValueProInfo.PropertyType), null);
                    //设置选择属性的值(1表示选择,0表示未选择)
                    if (item.Selected)
                        CheckedProInfo.SetValue(_t, Convert.ChangeType(1, CheckedProInfo.PropertyType), null);
                    else
                        CheckedProInfo.SetValue(_t, Convert.ChangeType(0, CheckedProInfo.PropertyType), null);
    
                    //如果扩展字段不为空
                    if (_dicFields != null && _dicFields.Count >= 0)
                    {
                        foreach (var _key in _dicFields.Keys)
                        {
                            PropertyInfo _pro = _type.GetProperty(_key);
                            if (_dicFields[_key] == "NewGuid()")
                                _pro.SetValue(_t, Convert.ChangeType(Guid.NewGuid().ToString().Replace("-", "").ToUpper(), _pro.PropertyType), null);
                            else
                                _pro.SetValue(_t, Convert.ChangeType(_dicFields[_key], _pro.PropertyType), null);
                        }
                    }
                    lst.Add(_t);
                }
                return lst;
                #endregion
            }
            return null;
        }
    
        /// <summary>
        /// 绑定单选框组
        /// </summary>
        /// <typeparam name="T">类类型</typeparam>
        /// <param name="lst">泛型集合</param>
        /// <param name="ID">复选框组ID</param>
        /// <param name="TextPropertyName">需要绑定的文本属性字段名(大写小都必须一致)</param>
        /// <param name="ValuePropertyName">需要绑定的值属性字段名(大写小都必须一致)</param>
        /// <param name="CheckedPropertyName">需要绑定的选择属性字段名(大写小都必须一致)</param>
        /// <param name="isCheckedPropertyName">是否是选择属性字段名,如果如false,则CheckedPropertyName表示选中的值</param>
        protected void BindRadioGroup<T>(List<T> lst, string ID, string TextPropertyName, string ValuePropertyName, string CheckedPropertyName, bool isCheckedPropertyName)
        {
            if (lst != null && lst.Count > 0)
            {
                Control _control = this.FindControl(ID);
                if (_control is Ext.Net.RadioGroup)
                {
                    RadioGroup groupRadios = this.FindControl(ID) as Ext.Net.RadioGroup;
                    if (groupRadios == null)
                        return;
                    //groupRadios.SubmitValue = true;
    
                    if (lst.Count <= 4)
                    {
                        groupRadios.ColumnsNumber = lst.Count;
                    }
                    else
                    {
                        groupRadios.ColumnsNumber = 4;
                    }
                    groupRadios.Items.Clear();
                    foreach (var item in lst)
                    {
                        T t = item;
                        Type type = t.GetType();
                        Ext.Net.Radio rdo = new Ext.Net.Radio();
                        PropertyInfo TextProInfo = type.GetProperty(TextPropertyName);
                        if (TextProInfo == null)
                            ThrowNullException(type, TextPropertyName);
    
                        PropertyInfo ValueProInfo = type.GetProperty(ValuePropertyName);
                        if (ValueProInfo == null)
                            ThrowNullException(type, ValuePropertyName);
    
                        object objText = TextProInfo.GetValue(t, null);
                        rdo.BoxLabel = objText == null ? string.Empty : objText.ToString();
                        object objValue = ValueProInfo.GetValue(t, null).ToString();
                        rdo.Tag = objValue == null ? string.Empty : objValue.ToString();
    
                        if (!isCheckedPropertyName)
                        {
                            if (rdo.Tag == CheckedPropertyName)
                                rdo.Checked = true;
                            groupRadios.Items.Add(rdo);
                            continue;
                        }
                        PropertyInfo CheckedProInfo = type.GetProperty(CheckedPropertyName);
                        if (CheckedProInfo == null)
                            ThrowNullException(type, CheckedPropertyName);
    
    
                        if (CheckedProInfo.GetValue(t, null).ToString() == "1")
                            rdo.Checked = true;
                        groupRadios.Items.Add(rdo);
                    }
                }
                else if (_control is RadioButtonList)
                {
                    RadioButtonList _rbl = _control as RadioButtonList;
                    _rbl.DataTextField = TextPropertyName;
                    _rbl.DataValueField = ValuePropertyName;
                    _rbl.DataSource = lst;
                    _rbl.RepeatDirection = RepeatDirection.Horizontal;
                    //_rbl.RepeatLayout = RepeatLayout.Flow;
                    _rbl.DataBind();
                    if (!isCheckedPropertyName)
                        _rbl.SelectedValue = CheckedPropertyName;
                }
    
            }
        }
    
        private static void ThrowNullException(Type type, string errorMsg)
        {
            StringBuilder sbPropertiesList = new StringBuilder(errorMsg);
            sbPropertiesList.Append("不存在!<br/>");
            PropertyInfo[] pros = type.GetProperties();
            foreach (var proItem in pros)
            {
                sbPropertiesList.Append(proItem.Name).Append("<br />");
            }
            throw new Exception(errorMsg + sbPropertiesList.ToString());
        }
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            try
            {
                SaveShopIno();
            }
            catch (Exception ex)
            {
                NBShopCommon.LogManager.WriteErrorLog(ex);
            }
    
        }
    
        private void SaveShopIno()
        {
            Shopkeeper keeper = new Shopkeeper();
            SetValues(keeper, this);
            //店主ID
            keeper.Id = ShopkeeperID;
            #region 性别
            if (ddlSex.SelectedItem != null)
            {
                keeper.SexTypeId = ddlSex.SelectedItem.Value;
                keeper.SexTypeName = ddlSex.SelectedItem.Text;
            }
            #endregion
            #region 证件类型
            if (ddlTypeOfIdentificationDocument.SelectedItem != null)
            {
                keeper.CredentialsId = ddlTypeOfIdentificationDocument.SelectedItem.Value;
                keeper.CredentialsName = ddlTypeOfIdentificationDocument.SelectedItem.Text;
            }
            #endregion
            #region 婚姻状态
            if (ddlMaritalStatus.SelectedItem != null)
            {
                keeper.MaritalStatus = ddlMaritalStatus.SelectedItem.Value;
                keeper.MaritalStatusName = ddlMaritalStatus.SelectedItem.Text;
            }
            #endregion
            //店铺ID
            keeper.ShopId = ShopID;
            #region 商圈信息
            List<BusinessDistrict> lstBusinessDistrict = new List<BusinessDistrict>();
            Dictionary<string, string> dicBusinessDistrictFields = new Dictionary<string, string>();
            dicBusinessDistrictFields.Add("BDId", "NewGuid()");
            dicBusinessDistrictFields.Add("ShopId", ShopID);
            SetValueFromCheckGroup(lstBusinessDistrict, "cblBusinessDistrict", "BDTypeName", "BDTypeId", "CheckValue", "NBShopMode.Shop.BusinessDistrict", dicBusinessDistrictFields);
            #endregion
            #region 临近竞争店
            List<Compete> lstCompete = new List<Compete>();
            Dictionary<string, string> dicCompeteFields = new Dictionary<string, string>();
            dicCompeteFields.Add("CompeteId", "NewGuid()");
            dicCompeteFields.Add("ShopId", ShopID);
            SetValueFromCheckGroup(lstCompete, "cblCompeteShops", "CompeteShopName", "CompeteShopId", "CheckValue", "NBShopMode.Shop.Compete", dicCompeteFields);
            #endregion
            #region 配套设备
            List<SupportingFacility> lstSupportingFacility = new List<SupportingFacility>();
            Dictionary<string, string> dicSupportingFacilityFields = new Dictionary<string, string>();
            dicSupportingFacilityFields.Add("SFId", "NewGuid()");
            dicSupportingFacilityFields.Add("ShopId", ShopID);
            SetValueFromCheckGroup(lstSupportingFacility, "cblCompeteShops", "SFTypeName", "SFTypeId", "CheckValue", "NBShopMode.Shop.SupportingFacility", dicSupportingFacilityFields);
            #endregion
            Shop shop = new Shop();
            SetValues(shop, this);
            //店铺ID
            shop.ShopId = ShopID;
            #region 区域、城市、省份、店铺持有类型、临街状态、十字路口、检测仪
            #region 区域
            if (ddlArea.SelectedItem != null)
            {
                shop.AreaId = ddlArea.SelectedItem.Value;
                shop.AreaName = ddlArea.SelectedItem.Text;
            }
            #endregion
            #region 城市
            if (ddlCitys.SelectedItem != null)
            {
                shop.CityId = ddlCitys.SelectedItem.Value;
                shop.CityName = ddlCitys.SelectedItem.Text;
            }
            #endregion
            #region 省份
            if (ddlProvince.SelectedItem != null)
            {
                shop.ProvinceId = ddlProvince.SelectedItem.Value;
                shop.ProvinceName = ddlProvince.SelectedItem.Text;
            }
            #endregion
            #region 店铺类型
            if (ddlShopType.SelectedItem != null)
            {
                shop.ShopTypeId = ddlShopType.SelectedItem.Value;
                shop.ShopTypeValue = ddlShopType.SelectedItem.Text;
            }
            #endregion
            #region 店铺持有类型
            if (ddlOwnerType.SelectedItem != null)
            {
                shop.HoldStatus = ddlOwnerType.SelectedItem.Text;
                shop.HoldStatusValue = ddlOwnerType.SelectedItem.Value;
            }
            #endregion
            #region 店铺临街状态
            if (ddlFrontageState.SelectedItem != null)
            {
                shop.FrontageStatus = ddlFrontageState.SelectedItem.Text;
                shop.FrontageStatusValue = ddlFrontageState.SelectedItem.Value;
            }
            #endregion
            #region 店铺所处十字路口
            if (ddlCrossroadsState.SelectedItem != null)
            {
                shop.CrossroadsStatus = ddlCrossroadsState.SelectedItem.Text;
                shop.CrossroadsStatusValue = ddlCrossroadsState.SelectedItem.Value;
            }
            #endregion
            #region 检测仪状态
            //rblDetectorState.CheckedItems.ForEach(delegate(Radio radio)
            //{
            //    shop.CheckMeterStatus = radio.BoxLabel;
            //    shop.CheckMeterStatusValue = radio.Tag;
            //});
            if (rblDetectorState.SelectedItem != null)
            {
                shop.CheckMeterStatus = rblDetectorState.SelectedItem.Text;
                shop.CheckMeterStatusValue = rblDetectorState.SelectedItem.Value;
            }
            #endregion
            #endregion
            #region 设置面积
            List<Acreage> lstAcreage = new List<Acreage>();
            for (int i = 0; i < fpnlAcreage.Items.Count; i++)
            {
                Acreage acr = new Acreage();
                acr.AcreageId
                    = shopServices.GetNewGuid();
    
                #region 面积类型ID
                Hidden hf = fpnlAcreage.FindControl("AcreageTypeId" + i) as Hidden;
                if (hf != null)
                    acr.AcreageTypeId = hf.Value.ToString();
                #endregion
                #region 面积值
                NumberField txtAcreageValue = fpnlAcreage.FindControl("Acreage" + i) as NumberField;
                if (txtAcreageValue != null)
                {
                    acr.AcreageTypeName = txtAcreageValue.FieldLabel.Substring(0, txtAcreageValue.FieldLabel.Length - 5);
                    acr.AcreageValue = Convert.ToDecimal(txtAcreageValue.Text);
                }
                #endregion
    
                #region 高
                NumberField txtAcreageHigh = fpnlAcreage.FindControl("AcreageHigh" + i) as NumberField;
                if (txtAcreageHigh != null)
                    acr.High = Convert.ToDecimal(txtAcreageHigh.Text);
    
                #endregion
                #region 长
                NumberField txtAcreageLength = fpnlAcreage.FindControl("AcreageLength" + i) as NumberField;
                if (txtAcreageLength != null)
                    acr.Length = Convert.ToDecimal(txtAcreageLength.Text);
                #endregion
    
                #region 宽
                NumberField txtAcreageWide = fpnlAcreage.FindControl("AcreageWide" + i) as NumberField;
                if (txtAcreageLength != null)
                    acr.Wide = Convert.ToDecimal(txtAcreageWide.Text);
                #endregion
    
                acr.ShopId = ShopID;
                lstAcreage.Add(acr);
            }
            #endregion
            #region 设置店铺信息
            ShopInfo shopInfo = new ShopInfo()
            {
                IlAcreage = lstAcreage,
                IlBusinessDistrict = lstBusinessDistrict,
                IlCompete = lstCompete,
                IlSupportingFacility = lstSupportingFacility,
                Shop = shop,
                Shopkeeper = keeper
            };
            #endregion
    
            NBShopCommon.LogManager.WriteTraceLog(NBShopCommon.JSONHelper.ToJSON(shopInfo));
        }
        private void SetFields(int _width, string _msgTarget, IEnumerable<XElement> fields)
        {
            foreach (var item in fields)
            {
                //最大允许长度
                int? _maxLength = null;
                //显示文本
                string _labelText = string.Empty;
                //是否允许空
                bool _allowBlank = true;
                //文本控件ID
                string textControlID = item.Attributes("TextControlID").First().Value;
                //值(显示的文本)
                _labelText = item.Value;
                var control = this.FindControl(textControlID);
                //最大允许长度
                var attrMaxLength = item.Attributes("MaxLength").FirstOrDefault();
                if (attrMaxLength != null && MyRegex.IsNumberRegex(attrMaxLength.Value))
                    _maxLength = Convert.ToInt32(attrMaxLength.Value);
                //是否可为空
                var attrAllowBlank = item.Attributes("AllowBlank").FirstOrDefault();
                if (attrAllowBlank != null)
                {
                    switch (attrAllowBlank.Value.ToLower())
                    {
                        case "false":
                            _allowBlank = false;
                            break;
                        case "true":
                            _allowBlank = true;
                            break;
                    }
                }
                if (control is TextFieldBase)
                {
                    Ext.Net.TextFieldBase txt = control as Ext.Net.TextFieldBase;
                    txt.FieldLabel = _labelText;
                    txt.AllowBlank = _allowBlank;
                    if (txt.Width.IsEmpty || txt.Width == null)
                        txt.Width = _width;
                    if (control is NumberField)
                    {
                        if (txt.Text.Length == 0)
                            txt.Text = "0";
                    }
                    txt.MsgTarget = MessageTarget.Side;
                }
                else if (control is Ext.Net.ComboBox)
                {
                    Ext.Net.ComboBox txt = control as Ext.Net.ComboBox;
                    txt.FieldLabel = _labelText;
                    txt.AllowBlank = _allowBlank;
                    txt.Width = _width;
                    txt.MsgTarget = MessageTarget.Side;
                }
                else if (control is Ext.Net.CheckboxBase)
                {
                    Ext.Net.CheckboxBase txt = control as Ext.Net.CheckboxBase;
                    txt.FieldLabel = _labelText;
                    txt.MsgTarget = MessageTarget.Side;
                    txt.LazyMode = LazyMode.Instance;
                }
                else if (control is Ext.Net.CheckboxGroupBase)
                {
                    Ext.Net.CheckboxGroupBase txt = control as Ext.Net.CheckboxGroupBase;
                    txt.FieldLabel = _labelText;
                    txt.AllowBlank = _allowBlank;
                    txt.MsgTarget = MessageTarget.Side;
                }
            }
        }
        /// <summary>
        /// 设置类型的属性值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="userControl">用户控件</param>
        public static void SetValues<T>(T t, System.Web.UI.UserControl userControl)
        {
            Type type = t.GetType();
            if (type.IsClass)
            {
                var properties = type.GetProperties();
                foreach (var item in properties)
                {
                    if (item.CanWrite)
                    {
                        System.Web.UI.Control control = userControl.FindControl("txt" + item.Name);
                        if (control != null)
                        {
                            string text = string.Empty;
                            if (control is Ext.Net.TextFieldBase)
                                text = (control as TextFieldBase).Text.Trim();
                            if (item.PropertyType.IsEnum)
                            {
                                item.SetValue(t, Enum.ToObject(item.PropertyType, text), null);
                            }
                            else
                            {
                                item.SetValue(t, Convert.ChangeType(text, item.PropertyType), null);
                            }
                        }
                    }
                }
            }
        }
    
        public string ShopID
        {
            get
            {
                return Session["ShopID"].ToString();
            }
            set
            {
                Session["ShopID"] = value;
            }
        }
    
        public string ShopkeeperID { get; set; }
    
    
    }
  4. #4

    this is the xml file

    Below is the use of Xml files.The project has not been finished, stuck in the above that place.I hope everybody can help me find the reasons.
    <?xml version="1.0" encoding="utf-8" ?>
    <!--?????????????基本配置属性????????????????-->
    <!--TextControlID:文本控件服务器ID。-->
    <!--LabelControlID:Label显示控件服务器ID。不设置或为空则表示根据TextControlID匹配。-->
    <!--?????????????验证配置属性????????????????-->
    <!--AllowBlank:是否允许为空。可选值为{false、True}。不区分大小写。默认为True。-->
    
    <!--MaxLength:最大允许输入的字符数。必须为整数。-->
    
    <!--ValidationExpression:正则表达式。默认无。-->
    
    
    <!--MaximumValue:最大允许的值(针对数值和Date有效)。默认无。-->
    <!--MinimumValue:最小允许的值(针对数值和Date有效)。默认无。-->
    <!--DataType:数据类型。可选值为{Integer、Double、Currency、Date、String}。默认String,表示不受类型限制。该属性可以结合MaximumValue和MinimumValue使用(更精确验证),也可以结合Operator使用(数据类型验证、比较验证)。-->
    <!--Operator:比较操作模式。可选值为{DataTypeCheck、Equal、GreaterThan、 GreaterThanEqual、 LessThan、 LessThanEqual、 NotEqual}。默认无。要启用该属性,需设置DataType属性。-->
    <!--ControlToCompare:要比较的控件ID(与Operator结合使用,否则可能会引发异常。)。默认无。-->
    <!--ValueToCompare:要比较的值(与Operator结合使用,否则可能会引发异常。)。默认无。-->
    
    <!--请根据以上说明来配置基本属性和验证属性。否则可能配置无效或引发异常。-->
    
    <!--??????????????附:常用正则表达式????????????????-->
    <!--Telphone:(\d{3}-\d{8}|\d{4}-\d{8}|\d{4}-\d{7}|\d{3}-\d{7})(-\d{2,8})?-->
    <!--Email:^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$-->
    <!--MobilePhone:^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[0-9]\d{8}$-->
    <!--Url:^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$-->
    <!--IdentityCard:^\\d{15}$|^\\d{18}$-->
    <!--Date:^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$-->
    <!--DateTime:^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$-->
    <!--Fax:^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$-->
    <!--Contains only letters(只含字母):^[A-Za-z]+$-->
    <!--Contains only Chinese(只含中文):^[\u4e00-\u9fa5]+$-->
    <!--????????????????????????????????????????????-->
    <!--MsgTarget[qtip:当鼠标移动到控件上面时显示提示;title-在浏览器的标题显示;under-在控件的底下显示错误提示;side-在控件右边显示一个错误图标,鼠标指向图标时显示错误提示. 默认值;id-[element id]错误提示显示在指定id的HTML元件中]-->
    <!--ColumnsNumber:CheckboxGroup、RadioGroup 的列数-->
    <FieldConfig>
      <GlobalDefaultConfig>
        <Width>250</Width>
        <!--<MsgTarget>Side</MsgTarget>-->
      </GlobalDefaultConfig>
      <Fields>
        <Field TextControlID="txtName" AllowBlank="false" MaxLength="20"><![CDATA[主持老师]]></Field>
        <Field TextControlID="ddlSex">性  别</Field>
        <Field TextControlID="txtBirthday" DataType="Date" Operator="DataTypeCheck">出生年月</Field>
        <Field TextControlID="txtNationality">国  籍</Field>
        <Field TextControlID="ddlMaritalStatus" >婚姻状况</Field>
        <Field TextControlID="txtHighestEducation" >最高学历</Field>
        <Field TextControlID="ddlTypeOfIdentificationDocument" AllowBlank="false">证件名称</Field>
        <Field TextControlID="txtIDNO" AllowBlank="false" MaxLength="20">证件号码</Field>
        <Field TextControlID="txtQQ" >QQ / MSN</Field>
        <Field TextControlID="txtHomePhone" ValidationExpression="(\d{3}-\d{8}|\d{4}-\d{8}|\d{4}-\d{7}|\d{3}-\d{7})(-\d{2,8})?" MaxLength="15">宅  电</Field>
        <Field TextControlID="txtMobilePhone" AllowBlank="false" ValidationExpression="^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[0-9]\d{8}$" MaxLength="11">手  机</Field>
        <Field TextControlID="txtEmail" ValidationExpression="^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$">E-Mail</Field>
        <Field TextControlID="txtShopCount" DataType="Integer" MinimumValue="0" >店  数</Field>
        <Field TextControlID="txtOpeningTime"  DataType="Date" Operator="DataTypeCheck">开业时间</Field>
        <Field TextControlID="ddlArea" >所属大区</Field>
        <Field TextControlID="ddlProvince" >所属省份</Field>
        <Field TextControlID="ddlCitys" >所属城市</Field>
        <Field TextControlID="txtShopName" AllowBlank="false" MaxLength="20">店  名</Field>
        <Field TextControlID="txtShopPhone" AllowBlank="false" ValidationExpression="(\d{3}-\d{8}|\d{4}-\d{8}|\d{4}-\d{7}|\d{3}-\d{7})(-\d{2,8})?" MaxLength="12">店铺电话</Field>
        <Field TextControlID="ddlShopType" >类  别</Field>
        <Field TextControlID="txtOracleNO" >Oralce号</Field>
        <Field TextControlID="txtContractNO" >协议号</Field>
        <Field TextControlID="txtAddress" >店  址</Field>
        <Field TextControlID="cblBusinessDistrict" >店商圈</Field>
        <Field TextControlID="ddlOwnerType" >店  铺</Field>
        <Field TextControlID="ddlFrontageState" >是否临街</Field>
        <Field TextControlID="ddlCrossroadsState" >所处十字路口店</Field>
        <Field TextControlID="rblDetectorState" >十大功能检测仪</Field>
        <Field TextControlID="txtFloor" DataType="Integer" MinimumValue="0" MaximumValue="150" >所处楼层</Field>
        <Field TextControlID="txtFloorNum" DataType="Integer" MinimumValue="0" MaximumValue="150" >总楼层数</Field>
        <Field TextControlID="txtSignboardAcreage" DataType="Double" MinimumValue="0" >店招面积(M²)</Field>
        <Field TextControlID="txtEmployeeNum" DataType="Integer" MinimumValue="0" >雇员数(人)</Field>
        <Field TextControlID="txtTechnicianNum" DataType="Integer" MinimumValue="0" >技工数(人)</Field>
        <Field TextControlID="txtCustomerNum" DataType="Integer" MinimumValue="0" >客户数(个)</Field>
        <Field TextControlID="txtRoomNum" DataType="Integer" MinimumValue="0" >房间数(间)</Field>
        <Field TextControlID="txtBedNum" DataType="Double" MinimumValue="0" >床位数(床)</Field>
        <Field TextControlID="txtMonthlySales" DataType="Double" MinimumValue="0" >月销售额(¥)</Field>
        <Field TextControlID="txtLastDecorationDate"  DataType="Date" Operator="DataTypeCheck">上次装修时间</Field>
        <Field TextControlID="txtCompeteRemark">描述</Field>
        <Field TextControlID="txtInstallationValidity"  DataType="Date" Operator="DataTypeCheck">安装有效期</Field>
        <Field TextControlID="cblCompeteShops" >临近竞争店</Field>
        <Field TextControlID="txtRemark">需求建议</Field>
      </Fields>
    </FieldConfig>
  5. #5
    Unfortunately, when I copied the code you posted and ran it, I've got a lot of exceptions.
  6. #6

    Problem has been solved

    Problem has been solved. I think this is a bug.Because I Use
    <%=FormPanel1.ClientID %>.getForm().getValues(true)'
    Unable to get to the checkboxGroup value.

    So I use the following methods.

    <script src="/js/jquery-1.4.4.min.js" type="text/javascript"></script>
        Ext.onReady(function () {
            top.Ext.getCmp('frmStatesRequestList').maximize();
            setLabelClass();
            setGroupValues(<%=cblBusinessDistrict.ClientID %>,<%=cblBusinessDistrictHidden.ClientID %>);
            setGroupValues(<%=cblCompeteShops.ClientID %>,<%=cblCompeteShopsHidden.ClientID %>);
            setGroupValues(<%=cblHardwares.ClientID %>,<%=cblHardwaresHidden.ClientID %>);
            setGroupValues(<%=rblDetectorState.ClientID %>,<%=rblDetectorStateHidden.ClientID %>);
        });
       
        function setGroupValues(cblID,cblHidden) {
             var cbos = $('#'+cblID.id+' input[type=checkbox],input[type=radio]');
             cbos.change(function () {
                var items=cblID.getValue();
                if (items!=null && items.length==undefined) {
                    cblHidden.setValue(items.tag);
                    return;
                }
                var strValue='';
                if (items!=null) {
                    for (var i = 0; i < items.length; i++) {
                          strValue+=items[i].tag+";";
                    }
                }
                cblHidden.setValue(strValue);
            });
        }
    Last edited by Daniil; Feb 28, 2011 at 5:15 AM. Reason: Please use [CODE] tags for code only
  7. #7
    Quote Originally Posted by QingXin View Post
    Problem has been solved. I think this is a bug.Because I Use
    <%=FormPanel1.ClientID %>.getForm().getValues(true)'
    Unable to get to the checkboxGroup value.
    It appears to be working fine on my side. I use the sample below to test.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <script type="text/javascript">
            var onClick = function() {
                var values = <%=FormPanel1.ClientID %>.getForm().getValues(),
                    s;
                s = "TextField1: " + values.TextField1 + "\n";
                s += "CheckboxGroup1: ";
                if (values.CheckboxGroup1) {
                    if (Ext.isArray(values.CheckboxGroup1)) {
                        s += values.CheckboxGroup1[0] + " ";
                        s += values.CheckboxGroup1[1];
                    } else {
                        s += values.CheckboxGroup1;
                    }
                } else {
                    s += "no checked"
                }
                alert(s);
            }
        </script>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:TextField ID="TextField1" runat="server" Text="Test" />
                    <ext:CheckboxGroup runat="server" ColumnsNumber="1">
                        <Items>
                            <ext:Checkbox 
                                ID="Checkbox1" 
                                runat="server" 
                                Name="CheckboxGroup1" 
                                BoxLabel="1" 
                                Checked="true" />
                            <ext:Checkbox 
                                ID="Checkbox2" 
                                runat="server" 
                                Name="CheckboxGroup1" 
                                BoxLabel="2" />
                        </Items>
                    </ext:CheckboxGroup>
                </Items>
            </ext:FormPanel>
            <ext:Button runat="server" Text="Get values">
                <Listeners>
                    <Click Fn="onClick" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  8. #8
    Thank you!I made several tests,Finally found out the reason.Look at the following code.
            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
            <ext:FormPanel ID="FormPanel1" Collapsible="true" Icon="PageAdd" runat="server" Title="Test"
                MonitorValid="true" Padding="5" ButtonAlign="Right" Width="830px" Layout="Form">
                <Items>
                    <ext:FormPanel ID="fpnlShopInfo" Icon="PhoneAdd" Border="true" Collapsible="true"
                        runat="server" Title="Test1" AutoHeight="true" LabelWidth="120">
                        <Items>
                            <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel16"
                                Layout="Column">
                                <Items>
                                    <ext:CheckboxGroup ID="cblBusinessDistrict" runat="server">
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:FormPanel>
                        </Items>
                    </ext:FormPanel>
                    <ext:FormPanel ID="FormPanel2" Icon="PhoneEdit" Border="true" Collapsible="true"
                        runat="server" Title="Test2" AutoHeight="true" LabelWidth="120">
                        <Content>
                            <ext:FormPanel runat="server" PaddingSummary="0" Border="false" ID="FormPanel3" Layout="Column">
                                <Items>
                                    <ext:CheckboxGroup ID="cboTest2" runat="server">
                                    </ext:CheckboxGroup>
                                </Items>
                            </ext:FormPanel>
                        </Content>
                    </ext:FormPanel>
                </Items>
                <Buttons>
                    <ext:Button ID="Button1" runat="server" Icon="Disk" Text="Test1">
                        <DirectEvents>
                            <Click OnEvent="Save_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="Button2" runat="server" Icon="Disk" Text="Test2">
                        <DirectEvents>
                            <Click OnEvent="Test2_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        protected void Page_Load(object sender, EventArgs e)
        {
            cblBusinessDistrict.ColumnsNumber = cboTest2.ColumnsNumber = 5;
            for (int i = 0; i < 10; i++)
            {
                Ext.Net.Checkbox cbo = new Ext.Net.Checkbox();
                cbo.BoxLabel = i + "Text";
                cbo.Tag = i.ToString();
                cbo.InputValue = i + "Value";
                cblBusinessDistrict.Items.Add(cbo);
                Ext.Net.Checkbox cbo1 = new Ext.Net.Checkbox();
                cbo1.BoxLabel = i + "Text";
                cbo1.Tag = i.ToString();
                cbo1.InputValue = i + "Value";
                cboTest2.Items.Add(cbo1);
            }
        }
    
        protected void Save_Click(object sender, DirectEventArgs e)
        {
            string _str = string.Empty;
            foreach (var item in cblBusinessDistrict.Items)
            {
                _str += item.BoxLabel + ":" + item.InputValue + ":" + item.Checked + "\\n";
            }
            ResourceManager1.AddScript("alert('" + _str + "');");
        }
    
        protected void Test2_Click(object sender, DirectEventArgs e)
        {
            string _str = string.Empty;
            foreach (var item in cboTest2.Items)
            {
                _str += item.BoxLabel + ":" + item.InputValue + ":" + item.Checked + "\\n";
            }
            ResourceManager1.AddScript("alert('" + _str + "');");
        }
    Comparing the above code, you should be able to find reasons.But for a moment I still think impassability why this is so.Thank you very much.My English is very poor. Hope for your kind understanding without cause trouble.
    Last edited by Daniil; Mar 01, 2011 at 10:42 AM. Reason: Please use [CODE] tags for code only
  9. #9
    Yes, there is the problem. Here is a simplified sample to reproduce.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            string s = string.Empty;
            foreach (var item in this.CheckboxGroup1.Items)
            {
                s += item.BoxLabel + ": " + item.Checked + "<br/>";
            }
            X.MessageBox.Alert("Items", s).Show();
        }
    
        protected void Button2_Click(object sender, DirectEventArgs e)
        {
            string s = string.Empty;
            foreach (var item in this.CheckboxGroup2.Items)
            {
                s += item.BoxLabel + ": " + item.Checked + "<br/>";
            }
            X.MessageBox.Alert("Content", s).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:FormPanel runat="server" Title="Test1" ButtonAlign="Left" Width="150">
            <Items>
                <ext:CheckboxGroup ID="CheckboxGroup1" runat="server" ColumnsNumber="1">
                    <Items>
                        <ext:Checkbox runat="server" BoxLabel="1" />
                        <ext:Checkbox runat="server" BoxLabel="2" />
                    </Items>
                </ext:CheckboxGroup>
            </Items>
        </ext:FormPanel>
        <ext:Button runat="server" Text="Test1" OnDirectClick="Button1_Click" />
        <ext:FormPanel runat="server" Title="Test1" ButtonAlign="Left" Width="150">
            <Content>
                <ext:CheckboxGroup ID="CheckboxGroup2" runat="server" ColumnsNumber="1">
                    <Items>
                        <ext:Checkbox runat="server" BoxLabel="1" />
                        <ext:Checkbox runat="server" BoxLabel="2" />
                    </Items>
                </ext:CheckboxGroup>
            </Content>
        </ext:FormPanel>
        <ext:Button runat="server" Text="Test2" OnDirectClick="Button2_Click" />
        </form>
    </body>
    </html>
    Well, we don't recommend to use <Content> in FormPanel, it doesn't make sense. If you replace <Content> with <Items>, you would see that the problem is gone.
  10. #10
    Thank you very much.

Similar Threads

  1. Unable to add items in ToolBox
    By Admir in forum 2.x Help
    Replies: 3
    Last Post: May 24, 2012, 4:22 PM
  2. unable to start Ext.Net.DLL
    By vbmathew in forum 2.x Help
    Replies: 1
    Last Post: Mar 22, 2012, 7:26 AM
  3. Unable to scroll ???
    By mlafleur in forum 1.x Help
    Replies: 3
    Last Post: Oct 01, 2011, 7:39 PM
  4. Unable to DataBind EventStore
    By awptimus in forum 1.x Help
    Replies: 1
    Last Post: May 21, 2011, 11:40 AM
  5. Unable to Hide the Window
    By vivekrane1986 in forum 1.x Help
    Replies: 2
    Last Post: Jul 22, 2010, 4:48 AM

Tags for this Thread

Posting Permissions