Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make your life easier and create the checkboxes with checkboxlists: <a href="http://msdn.microsoft.com/de-de/library/system.web.ui.webcontrols.checkboxlist.aspx" rel="nofollow">http://msdn.microsoft.com/de-de/library/system.web.ui.webcontrols.checkboxlist.aspx</a></p> <pre><code>&lt;asp:CheckBoxList ID="SomeElement" runat="server" AutoPostBack="true" RepeatColumns="4" EnableViewState="true"&gt; &lt;/asp:CheckBoxList&gt; </code></pre> <p>With the Repeatcolumns property you are telling the element, that you infact want 4 columns, so the control will devide your 32 elements by 4 and group those checkboxes by the pack of 8.</p> <p>After this, you can iterate through every list like this:</p> <pre><code>foreach(var cb in checkboxlistID) { if(cb.Checked) { //do something } } </code></pre> <p>On top of that, here is some old code showing you how to fill a checkboxlist with data fetched from a SQL-query. You can ignore the if expression, which is checking if there is cached data, from which to fill all the checkboxes.</p> <pre><code>using (OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["database"].ConnectionString)) { string Query = @"SELECT * from level"; OleDbCommand command = new OleDbCommand(Query, connection); if (Session["SavedLevelItems"] != null) { CheckBoxListLevel.Items.Clear(); List&lt;ListItem&gt; SessionList = (List&lt;ListItem&gt;)Session["SavedLevelItems"]; foreach (var item in SessionList) { try { CheckBoxListLevel.Items.Add(item); } catch { } } } else { connection.Open(); CheckBoxListLevel.DataTextField = "bez_level"; CheckBoxListLevel.DataValueField = "id_level"; OleDbDataReader ListReader = command.ExecuteReader(); CheckBoxListLevel.DataSource = ListReader; CheckBoxListLevel.DataBind(); ListReader.Close(); ListReader.Dispose(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload