关于dropdownlist的问题

来源:互联网 发布:windows如何安装redis 编辑:程序博客网 时间:2024/05/18 00:29

 本人初学.NET,经常碰到些问题,一般自己查下资料,都可以搞定,今天这个问题实在是搞不定,希望朋友们帮忙.....

 

     首先参考图片


    

本人想在货品明细下的一个表格下添加几行明细,每行明细的第一个单元格内是一个下拉框,是货品列表,

其它的列,如:类型,规格,单位,价格,货币,初始化时都是空的,当下拉框下拉时,触发selectedIndexChanged事件,

类型,规格,单位,价格,货币就显示所选择的货品的明细,我只要填写数量和金额,就可以搞定这张订单了.

      以上是我的意图,但是在写代码时,发现下拉框的OnSelectedIndexChanged会有问题,报错为

 

编译器错误信息: CS0122: “System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(System.EventArgs)”不可访问,因为它受保护级别限制
      不知道怎么办,希望达人帮忙,联系QQ:4894723或Email:f-h2001@163.com

    

            //-----------添加明细行---------------------            for (int i = 0; i <= 4; i++)            {                TableRow tr = new TableRow();                tr.Attributes.Add("onMouseOver", "this.style.background='#A0c6e5'");                tr.Attributes.Add("onMouseOut", "this.style.background='#FFFFFF'");                //名称                TableCell td1 = new TableCell();                DropDownList GoodsID = new DropDownList();                Goods gs = new Goods();                GoodsID.ID = "GoodsID_"+i;                GoodsID.DataSource = gs.ShowGoodsInfoList();                GoodsID.DataTextField = "GoodsName";                GoodsID.DataValueField = "GoodsID";                GoodsID.DataBind();                GoodsID.Items.Insert(0, li);                GoodsID.AutoPostBack = true;                //GoodsID.OnSelectedIndexChanged = GoodsID_SelectedIndexChanged(Convert.ToInt32(GoodsID.SelectedValue), i);                //GoodsID.SelectedIndexChanged += new System.EventHandler(GoodsID_SelectedIndexChanged);                td1.Controls.Add(GoodsID);                tr.Cells.Add(td1);                //类型                TableCell td2 = new TableCell();                Label TypeName = new Label();                TypeName.ID = "TypeName_" + i;                td2.Controls.Add(TypeName);                tr.Cells.Add(td2);                //规格                TableCell td3 = new TableCell();                Label Spec = new Label();                Spec.ID = "Spec_" + i;                td3.Controls.Add(Spec);                tr.Cells.Add(td3);                //单位                TableCell td4 = new TableCell();                Label Unit = new Label();                Unit.ID = "Unit_" + i;                td4.Controls.Add(Unit);                tr.Cells.Add(td4);                //价格                TableCell td5 = new TableCell();                Label Price = new Label();                Price.ID = "Price_" + i;                td5.Controls.Add(TypeName);                tr.Cells.Add(td5);                //货币                TableCell td6 = new TableCell();                Label CurrencyName = new Label();                CurrencyName.ID = "CurrencyName_" + i;                td6.Controls.Add(CurrencyName);                tr.Cells.Add(td6);                //数量                TableCell td7 = new TableCell();                TextBox Qty = new TextBox();                Qty.ID = "Qty_" + i;                Qty.CssClass = "smallbox";                td7.Controls.Add(Qty);                tr.Cells.Add(td7);                //金额                TableCell td8 = new TableCell();                TextBox Amount = new TextBox();                Amount.ID = "Amount_" + i;                Amount.CssClass = "smallbox";                td8.Controls.Add(Amount);                tr.Cells.Add(td8);                OrderDetailList.Rows.Add(tr);            }
原创粉丝点击