GridView中使用CheckBox

asp.net中checkbox是向服務器提交時才能觸發事件

把該控件的autopostback設置爲true,才能響應事件


 protected void Checkbox_CheckedChanged1(object sender, EventArgs e)
        {
            string id = string.Empty;
            foreach (GridViewRow gr in this.newsTable.Rows)
            {
                CheckBox CB = (CheckBox)gr.FindControl("ChkItem");
                if (CB.Checked)
                {
                    id += this.newsTable.DataKeys[gr.RowIndex]["InfoTableOID"].ToString();
                }
            }
            this.hidden.Value = id;
            
        }

發佈了21 篇原創文章 · 獲贊 1 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章