获取checkboxlist当前选定的值


 protected void Button3_Click(object sender, EventArgs e)
    {
        if (CheckBoxList1.SelectedValue != null && CheckBoxList1.SelectedValue != "")
        {
            string chkSelect = "";
            int myid = 0;
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected == true)
                    chkSelect += CheckBoxList1.Items[i].Value + ",";
            }
            if (Request["id"] != null && Request["id"] != "")
            {
                myid = Convert.ToInt32(Request["id"]);
            }
            string sql = "update tbMember_cnmj set nid ='" + chkSelect + "' where guid = " + myid;
            int g = SqlHelper.ExecuteNonQuery(sql);
            if (g > 0)
            {
                Response.Write("<script>alert('修改成功');window.location='UserNetName.aspx'</script>");
            }

        }
        else
        {
            Response.Write("<script>alert('请至少选择一个发布平台!');window.location=window.location</script>");
        }
    }

posted @ 2010-04-24 09:26  迷、踪  阅读(489)  评论(0编辑  收藏  举报