select multi option in checkbox group in one time

Such as:
there is a checkbox group in a datalist named datalist1. we need to catch the name selected through pressing the button2. the codes is following.
protected void Button2_Click(object sender, EventArgs e)
    {
        string selectname = "";
        for (int i = 0; i < DataList1.Items.Count; i++)
        {
            bool status = ((CheckBox)DataList1.Items[i].FindControl("CK1")).Checked;
            string username = ((TextBox)DataList1.Items[i].FindControl("TextBox1")).Text;
            if (status)
                selectname += username+"&";
         }
        Response.Redirect("selectcheckbox.aspx?selectname=" + selectname);
}

你可能感兴趣的:(checkbox)