www.webdeveloper.com
Results 1 to 3 of 3

Thread: asp.net and checkboxes - get list of choosen one's

  1. #1
    Join Date
    Jan 2003
    Location
    Israel
    Posts
    1,381

    asp.net and checkboxes - get list of choosen one's

    i have some checkboxes with the same name but diffrent id :
    PHP Code:
    <td bgcolor="#adc7cb"><input type="checkbox" name="trail_properties" id="TrailJump" runat="server" value="1">xxx&#1514;</td>
    <td bgcolor="#adc7cb"><input type="checkbox" name="trail_properties" id="TrailWater" runat="server" value="2">zzzzzz</td>
    <
    td bgcolor="#adc7cb"><input type="checkbox" name="trail_properties" id="TrailArch" runat="server" value="3">dfgdfg</td
    in ASP when i acces with Request("trail_properties") i have recived a list like :
    1,4,12 of the check boxes that have been choosend!
    why or how can i do the same in asp.net
    htnaks in advance
    pleg
    WebCssDesign
    Israel the best place to leave in = after Heaven

  2. #2
    Join Date
    Apr 2005
    Posts
    634
    use checkboxlist control

  3. #3
    Join Date
    Oct 2005
    Posts
    189
    here is sample code for using checkboxlist
    Code:
            con = new SqlConnection();
            con.ConnectionString = @"Data Source=#####;Initial Catalog=####;Integrated Security=True;Pooling=False";
            com = new SqlCommand();
            com.CommandText = "select * from tablename";
            com.Connection = con;
            con.Open();
            try
            {
                dr = com.ExecuteReader();
    
                DropDownList1.Items.Add("select catagory");
                while (dr.Read())
                {
                    if (!IsPostBack)
                    {
                        CheckBoxList1.Items.Add(dr.GetString(2));
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                con.Close();
            }
    u can got the selected checkbox
    Code:
    CheckBoxList1.SelectedItem
    Last edited by handshakeit; 04-20-2006 at 02:55 AM.
    ------------------------------------------
    Regards
    Abhishek Goel
    Software Developer in handshakeit (Handshake Infotech Pvt Ltd.)
    ------------------------------------------
    ActiveX controls

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles