Ext.NET -- 后台动态添加控件

    protected void btnAddItem_Click(object sender, EventArgs e)
        {
            int index = this.GetIndexVal();
            //Ext.Net.FieldSet fieldSet = new Ext.Net.FieldSet
            //{
            //    ID = "fieldSet" + index,
            //    Border = false
            //};

            HiddenField hf = new HiddenField
            {
                ID = "hidden" + index,

            };

            Ext.Net.Checkbox checkbox = new Ext.Net.Checkbox
            {
                ID = "checkbox" + index,
            };


            Ext.Net.FieldContainer fieldContainer = new Ext.Net.FieldContainer
            {
                ID = "fieldContainer" + index,
                Layout = "HBoxLayout",
                Border = false
            };

            Ext.Net.TextField itemField = new Ext.Net.TextField
            {
                ID = "itemField" + index,
                FieldLabel = "项目",
                LabelWidth = 50,
                Text = "项目"
            };
            Ext.Net.TextField accountField = new Ext.Net.TextField
            {
                ID = "accountField" + index,
                FieldLabel = "金额",
                LabelWidth = 50,
                Text = "金额"
            };
            fieldContainer.Items.Add(checkbox);
            fieldContainer.Items.Add(itemField);
            fieldContainer.Items.Add(accountField);

            splitItemForm.AddTo(this.splitFieldSet);
            //this.splitFieldSet.Items.Add(fieldContainer);


            //fieldSet.Items.Add(fieldContainer);

            //fieldSet.AddTo(this.splitFieldSet);

            Panel1.Expand();
            splitItemForm.Render();
        }

        private int GetIndexVal()
        {
            int idx = Convert.ToInt32(index) + 1;
            index = idx.ToString();
            this.Hidden1.Text = idx.ToString();
            return idx;
        }
       /* protected void btnDelItem_Click(object sender, EventArgs e)
        {
            Ext.Net.Checkbox checkbox = new Ext.Net.Checkbox();
            for (int i = 0; i < this.splitFieldSet.Items.Count; i++)
            {
                checkbox = (Ext.Net.Checkbox)this.splitFieldSet.Items[i].FindControl("checkbox" + i + "-inputEl");


                Control control = this.Panel1.FindControl(this.btnSave.ID);
                String btnSaveId = control.ID;
            }
        }
          */


发布了0 篇原创文章 · 获赞 14 · 访问量 5万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览