zoukankan      html  css  js  c++  java
  • 如何取得组合有一个Table里的CheckBox事件的对象

     private void TableBind(string HouseID,string HurdleID,string AnimalID,string Earmark,String i,bool b)
        { 

                TableRow Row = new TableRow();
                this.Table1.Rows.Add(Row);

                TableCell Cell = new TableCell();
                Cell.Width = Unit.Pixel(80);
       Cell.CssClass = "checkbox_td";
                Row.Cells.Add(Cell);
                CheckBox Chk = new CheckBox();
                Chk.ID = "CheckAnimalID" + i;
                Chk.Checked = b;
                Cell.Controls.Add(Chk);
                Chk.AutoPostBack = true;
                Chk.CheckedChanged += new EventHandler(Chk_CheckedChanged);
           

              TableCell Cell2 = new TableCell();
                Cell2.Width = Unit.Pixel(160);
                Row.Cells.Add(Cell2);
                Cell2.Visible = false;
                Label LblHurdleId = new Label();
                LblHurdleId.Text = HurdleID;
                Cell2.Controls.Add(LblHurdleId);

                TableCell Celln = new TableCell();
                Celln.Width = Unit.Pixel(220);
                Row.Cells.Add(Celln);
                TextBox AnimalNum = new TextBox();
                AnimalNum.Width = Unit.Pixel(100);
                AnimalNum.ID = "TxtChgNum" + i;
                AnimalNum.Text = "0";
                Celln.Controls.Add(AnimalNum); 

        }

     private void Chk_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox Chk = sender as CheckBox;//这个方法可取到所点的CheckBox对象
            string strId = Chk.ID;
               }

  • 相关阅读:
    Adjacent Bit Counts(uvalive)
    UVALIVE 4556 The Next Permutation
    vector(实现存图)
    最大连续子序列和(模板)
    全选和反选
    .netCore上传图片,要用FormFileCollection ,不能用List
    .NET-Core中 HttpContext.Response.Write() 中文输出乱码
    Core中Cookie和Session的新用法
    Ajax反填
    复选框变成单选
  • 原文地址:https://www.cnblogs.com/saimisei/p/1408658.html
Copyright © 2011-2022 走看看