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);
}

posted on 2008-01-04 21:29  飞天舞者  阅读(327)  评论(0编辑  收藏  举报

导航

For more information about me, feel free email to me winston.he@hotmail.com