By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,962 Members | 654 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,962 IT Pros & Developers. It's quick & easy.

How to get values in multiple checkbox?

P: 1
Can you please help me how to get the multiple values of checkbox.


Expand|Select|Wrap|Line Numbers
  1. @Html.Label("Revision of Records:")<br />
  2. @Html.CheckBox("Change Address", new { @class = "appType", @id = "ChangeAddress", @onclick = "clkChangeAddress()", @name = "nRevRecords" })  Change Address<br />
  3. @Html.CheckBox("Change Civil Status", new { @class = "appType", @id = "ChangeCivilStatus", @onclick = "clkChangeCivilStatus()", @name = "nRevRecords" }) Change Civil Status<br />
  4. @Html.CheckBox("Change Name", new { @class = "appType", @id = "ChangeName", @onclick = "clkChangeName()", @name = "nRevRecords" }) Change Name<br />
  5. @Html.CheckBox("Change Date of Birth", new { @class = "appType", @id = "ChangeDateBirth", @onclick = "clkChangeDateBirth()", @name = "nRevRecords" })  Change Date of Birth<br />
  6. @Html.CheckBox("Others", new { id = "ChkBoxOthers", @class = "appType", @onclick = "clkOthers()" })  Others <br />
  7.  
Jul 9 '18 #1
Share this Question
Share on Google+
2 Replies

P: 10
I think, you should going to Implement CheckBoxList in ASP.Net MVC.
visit this click here
Dec 1 '18 #2

P: 48
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true"%>    
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <script runat="server">
  6.     protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
  7.     {
  8.         var items = from ListItem li in CheckBoxList1.Items
  9.                     where li.Selected == true
  10.                     select li;
  11.  
  12.         Label1.Text = "you checked item(s).....<br />";
  13.  
  14.         foreach(ListItem li in items)
  15.         {
  16.             Label1.Text += li.Text + " | " + li.Value + "<br />";
  17.         }
  18.     }
  19. </script>        
  20.  
  21. <html>        
  22. <head id="Head1" runat="server">        
  23.     <title>asp.net checkboxlist multiple selected values</title>
  24. </head>        
  25. <body>        
  26.     <form id="form1" runat="server">        
  27.     <div>        
  28.         <h2 style="color:MidnightBlue; font-style:italic;">        
  29.             asp.net example - checkboxlist multiple selected values
  30.         </h2>        
  31.         <hr width="550" align="left" color="Gainsboro" />        
  32.         <asp:Label       
  33.             ID="Label1"       
  34.             runat="server"      
  35.             Text="check item(s) from checkboxlist."
  36.             Font-Size="X-Large"
  37.             Width="350"
  38.             >      
  39.         </asp:Label>      
  40.         <br /><br />
  41.         <asp:CheckBoxList 
  42.             ID="CheckBoxList1"
  43.             runat="server"
  44.             RepeatColumns="2"
  45.             AutoPostBack="true"
  46.             OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged"
  47.             >
  48.             <asp:ListItem Text="Rook" Value="1"></asp:ListItem>
  49.             <asp:ListItem Text="American Crow" Value="2"></asp:ListItem>
  50.             <asp:ListItem Text="White-necked Raven" Value="3"></asp:ListItem>
  51.             <asp:ListItem Text="Carrion Crow" Value="4"></asp:ListItem>
  52.             <asp:ListItem Text="Northern Raven" Value="5"></asp:ListItem>
  53.         </asp:CheckBoxList>  
  54.     </div>        
  55.     </form>        
  56. </body>        
  57. </html>
  58.  
Apr 22 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.