Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. CheckBoxes and checkboxlists

CheckBoxes and checkboxlists

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sroberts82
    wrote on last edited by
    #1

    Hi I was wondering if someone could maybe help me. I have a form which display a table of various data. At the end of each row in the table I wish to have a checkbox so on submission of the form I can determine which rows have been selected. The number of rows is variable depending on the results of a sql query. The way Im doing it at the minute is I have an asp:Table on my aspx page. In my code behind, for every sql result I get I add a row to the table, and one of the cells in the row contains a checkbox control. I dont like this though because I have to make up a different id for each one, and then go findcontrol on submission. Dont like this. Is there a better way to do it using checkboxlists? Thanks in advance stephen

    M 1 Reply Last reply
    0
    • S sroberts82

      Hi I was wondering if someone could maybe help me. I have a form which display a table of various data. At the end of each row in the table I wish to have a checkbox so on submission of the form I can determine which rows have been selected. The number of rows is variable depending on the results of a sql query. The way Im doing it at the minute is I have an asp:Table on my aspx page. In my code behind, for every sql result I get I add a row to the table, and one of the cells in the row contains a checkbox control. I dont like this though because I have to make up a different id for each one, and then go findcontrol on submission. Dont like this. Is there a better way to do it using checkboxlists? Thanks in advance stephen

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      If your data to diplay is as simple as string, then you can use the CheckBoxList control, because this control basically provides a multi selection checkbox group and each item of the control should be simple. In your case, if each row contains many things in there, then you might consider using a data-bound control like the DataGrid, DataList or Repeater control ( assuming you are using the ASP.NET 1.1). In the Item template you simply use the CheckBox control with its id for user selection, in the Click event handler you simply do a checking on the Checked property of this CheckBox to see what you should do, and in fact you don't need to worry about the Id of the checkbox control.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups