Wednesday 27 September 2017

Multiple Select (MultiSelect) DropDownList with CheckBoxes in ASP.Net using jQuery

Bootstrap Multiselect Dropdown with Checkboxes
Description:
In this example we explain that how to bind Multiple Select Dropdown List with Checkboxes in asp.net using jQuery. Or how to bind or populate multiselect Dropdown List with Checkboxes in asp.net using jQuery Ajax call. Or Bootstrap MultiSelect Dropdown List with Checkboxes in asp.net using JQuery.

Here we demonstrate how to implement a multiple select Dropdown List with checkboxes in asp.net using jQuery. Here we use Bootstrap Multiselect plugin to bind or populate multiselect deropdownlist with checkboxes in asp.net using jQuery.


Here we have to use the List Box control of the asp.net to populate the multiselect dropdownlist.or multiselect list box with checkbox using bootstrap multiselect dropdown list in asp.net.

Aspx Page: 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="SWS.Test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
<link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />
<script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('[id*=lstCourse]').multiselect({
            includeSelectAllOption: true //used for select all checkbox functionality
        });
    });
</script>
    <title>
Multiple Select (MultiSelect) DropDownList with CheckBoxes in ASP.Net using jQuery</title>
</head>
<body>
    <form id="form1" runat="server">
   <asp:ListBox ID="lstCourse" runat="server" SelectionMode="Multiple">
    <asp:ListItem Text="MBA" Value="1" />
    <asp:ListItem Text="MCA" Value="2" />
    <asp:ListItem Text="M.Sc" Value="3" />
    <asp:ListItem Text="M.Com" Value="4" />
    <asp:ListItem Text="M.Tech" Value="5" />
</asp:ListBox>
<asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" />
    </form>
</body>
</html>

 Aspx.cs Page:

protected void Submit(object sender, EventArgs e)
{
    string message = "";
    foreach (ListItem item in lstCourse.Items)
    {
        if (item.Selected)
        {
            message += item.Text + " " + item.Value + "\\n";
        }
    }
    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);
}



0 comments:

Post a Comment