Category Archives: CheckBoxList

CheckBoxList

[RESOLVED]Problem with CheckBoxListFor in MVC

Hello Everyone, I am trying to use checkboxlistfor in mvc to generate checkboxes dynamically for my items.Below is the my View code for checkboxlistfor:

<table class="form-table">
<tr>
<td>
<label>Searchfor</label>
</td>
<td>
@Html.CheckBoxListFor(model => model.PostedSearchableObject.PostedIds,
model => model.AvailableObjectTypes,
objecttype => objecttype.Id,
objecttype => objecttype.Name,
model => model.SelectedObjectTypes,
Position.Horizontal) </td>

When I run the solution I can see all the items that I need to have a checkbox for (ex: item1, item2, item3), but the problem is there are no Check-boxes next to each item for the user to select them. they are just a simple labels without a check box.

Does anyone has any idea why I can’t see the check-boxes?

thanks. 

Hi Benjaminsh,

Thanks for your post.

Benjaminsh

but the problem is there are no Check-boxes next to each item for the user to select them. they are just a simple labels without a check box.

According to your requirement,I did a sample.please refer to the following sample:

controller:

 [HttpGet]
        public ActionResult demo1()
        {
            WebCSDBEntities db = new WebCSDBEntities();
            return View(db.tblCities);
        }
        [HttpPost]
        public string demo1(IEnumerable<tblCity> cities)
        {
            if (cities.Count(x => x.IsSelected_) == 0)
            {
                return "you have not selected any city";
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("You selected-");
                foreach (tblCity city in cities)
                {
                    if (city.IsSelected_)
                    {
                        sb.Append(city.Name_ + ",");
                    }
                }
                sb.Remove(sb.ToString().LastIndexOf(","),1);
                return sb.ToString();
            }
        }

view:

@model reflectDemo.Models.tblCity

@{
    ViewBag.Title = "tblCity";
}

@*<h2>tblCity</h2>*@
@Html.HiddenFor(x=>x.Id)
@Html.HiddenFor(x=>x.Name_)
@Html.CheckBoxFor(x=>x.IsSelected_)
@Html.DisplayFor(x=>x.Name_)
@model IEnumerable<reflectDemo.Models.tblCity>

@{
    ViewBag.Title = "demo1";
}



<div style="font-family:Arial">
    <h2>demo1</h2>
    @using (Html.BeginForm())
    {
        @Html.EditorForModel()
        <br />
        <input type="submit" value="submit" /> 
    }
    
</div>

It worked on my side.

More information,you can check this:

#ASP.Net MVC- How to implement CheckBoxList

http://besttechnologyblog.com/2014/05/04/asp-net-mvc-how-to-implement-checkboxlist/

Hope this can be helpful.

Best Regards,

Eileen

Thank you very much for the time you spend to reply this thread. I found out the problem was due to overriding a CSS class.

Custom Check box issue

hi,

I am new to MVC. i have created custom Checkbox list control.

am able to bind the data to that control.

but Validation is not working when click on submit button.

My Custom CheckboxList

 public static MvcHtmlString CheckboxForSelectList<TModel, TProperty>(
         this HtmlHelper<TModel> htmlHelper,
         Expression<Func<TModel, TProperty>> expression,
         IEnumerable<SelectListItem> listOfValues, string name)
        {
            var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var sb = new StringBuilder();

            if (listOfValues != null)
            {
                // Create a radio button for each item in the list 
                foreach (SelectListItem item in listOfValues)
                {
                    // Generate an id to be given to the radio button field 
                    var id = string.Format("{0}_{1}", metaData.PropertyName, item.Value);

                    // Create and populate a radio button using the existing html helpers 
                    var label = htmlHelper.Label(id, HttpUtility.HtmlEncode(item.Text));
                    TagBuilder textBox = new TagBuilder("input");
                    textBox.Attributes.Add("type", "checkbox");
                    textBox.Attributes.Add("name", name);
                    textBox.Attributes.Add("id", "chk" + id);

                    textBox.Attributes.Add("aria-required", "true");
                    textBox.Attributes.Add("data-val", "true");
                    textBox.Attributes.Add("data-val-required", "This field is required.");
                    var chk = textBox.ToString(TagRenderMode.Normal);
                   // var chk = htmlHelper.CheckBoxFor(expression, new { id = id }).ToHtmlString();
                    
                    // Create the html string that will be returned to the client 
                    // e.g. <input data-val="true" data-val-required="You must select an option" id="TestRadio_1" name="TestRadio" type="radio" value="1" /><label for="TestRadio_1">Line1</label> 
                    sb.AppendFormat("<div class="CheckBox">{0}{1}</div>", chk, label);
                }
            }

            return MvcHtmlString.Create(sb.ToString());
        }

My UI Rendered code in browser:

<div class="CheckBox">
<input aria-required="true" data-val="true" data-val-required="This field is required." id="chkName_0" name="[4].Name" type="checkbox"></input>
<label id='Name_0'>Item 0</label>
</div>

<div class="CheckBox">
<input aria-required="true" data-val="true" data-val-required="This field is required." id="chkName_1" name="[4].Name" type="checkbox"></input>
<label id='Name_1'>Item 1</label>
</div>

<div class="CheckBox">
<input aria-required="true" data-val="true" data-val-required="This field is required." id="chkName_2" name="[4].Name" type="checkbox"></input>
<label id='Name_2'>Item 2</label>
</div>

<span class="field-validation-valid" data-valmsg-for="[4].Name" data-valmsg-replace="true"></span>

Please help me on this..

Thanks,

Sundar.

did you put the MVC validation scripts?

Hi,

ya..i have put the below script references..

<script
src="~/Scripts/jquery-1.7.1.min.js"></script>

<script
src="~/Scripts/jquery-ui-1.8.20.min.js"></script>

<script
src="~/Scripts/jquery.validate.min.js"></script>

<script
src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<script
src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

Thanks,

Sundar.

[RESOLVED]Simple checkbox filter on ado.net generated table

Hi there,

I’ve googled till my fingers are bleeding but I just can’t find or recognise the answer I seek. I’d appreciate any help, advice, links or sample code you can provide to get me past this block…

I’ve a model from an ADO.NET Entity Data Model, Controller MVC 5 Controller with views, using Entity Framework & a view.

MODEL:

 model3

namespace iCustomerSkills.Models
{
    using System;
    using System.Collections.Generic;
    
    public partial class Table_3
    {
        public int Id { get; set; }
        public string A { get; set; }
        public string B { get; set; }
        public string C { get; set; }
    }
}

CONTROLLER:

namespace iCustomerSkills.Controllers
{
    public class ThreeController : Controller
    {
        private WTEntities3 db = new WTEntities3();

        // GET: Three
        public async Task<ActionResult> Index()
        {
          return View(await db.Table_3.ToListAsync());
        } 

.......

VIEW:

@model IEnumerable<iCustomerSkills.Models.Table_3>
@using (Html.BeginForm())
{
    <div class="panel panel-default">
        <div class="panel-heading">General</div>
        <div class="panel-body">

            A:
            @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@
            @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true", Param1 = "ValueXXX" })
            <br />
            B:
            @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@
            @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true" })
            <br />
            C:
            @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@
            @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true" })
            <br />
          
        </div>
    </div>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.A)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.B)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.C)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.A)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.B)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.C)
            </td>
        </tr>
    }

</table>

Problem:

I would like to be able to select one or more of the checkbox & use the result(s) to filter the table, so

selecting "A"

 A
Yes
Yes
Yes
Yes

selecting "A" & "B"

 A   B
Yes Yes Yes Yes

YesNo
 

Hi XakTacit,

Thanks for your post.

There are some references:

#using a checkboxlist to filter data

http://forums.asp.net/t/1225130.aspx?using+a+checkboxlist+to+filter+data+

#ASP.NET
MVC
Display an HTML Table with Checkboxes to
Select Row Items

http://www.codeproject.com/Articles/706728/ASP-NET-MVC-Display-an-HTML-Table-with-Checkboxes

Hope this can be helpful.

Best Regards,

Eileen

[RESOLVED]Get Checkbox value and text

I have a checkbox list like this 

<asp:CheckBoxList ID="Checkbox_Cat_2B1" runat="server" Height="350px" Width="150px">
                        <asp:ListItem Value="Cat 1">Cat 1</asp:ListItem>
                        <asp:ListItem Value="Cat 2">Cat 2</asp:ListItem>
                        <asp:ListItem Value="Cat 3">Cat 3</asp:ListItem>
                        <asp:ListItem Value="Cat 4">Cat 4</asp:ListItem>
                        <asp:ListItem Value="Cat 5">Cat 5</asp:ListItem>
                        <asp:ListItem Value="Cat 6">Cat 6</asp:ListItem>
                        <asp:ListItem Value="Cat 7">Cat 7</asp:ListItem>
                        <asp:ListItem Value="Cat 8">Cat 8</asp:ListItem>
                    </asp:CheckBoxList>

I want to get the value and the text from the selected checkbox using jquery. How I am suppose to do this. Can any one help me please.

You may want to examine the "View Source" of the page to see the rendered control for the same.

You can then treat them like normal HTML controls and can use JQuery functions by using it’s IDs.

However a lot of goodies are in this article:

http://techbrij.com/checkboxlist-jquery-asp-net-operations

This should help you.

 

$( "#Checkbox" ).val()

gives you the value

You could just use a function like the following to grab your CheckBoxList and find any checked elements within it : 

<!-- Example jQuery Reference -->
<script src="http://localhost:62852/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
        $(function () {
            // When your GetCheckedValue button is clicked
            $("#GetCheckedValue").click(function (e) {
                // Loop through all of the checked elements in your CheckBoxList and output their values
                $("#<%= Checkbox_Cat_2B1.ClientID %> :checkbox:checked").each(function () {
                    // Alert the value
                    alert($(this).val());
                });
            });
        });
</script>

You can see a complete example below and
an interactive example here
:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://localhost:62852/Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            // When your GetCheckedValue button is clicked
            $("#GetCheckedValue").click(function (e) {
                // Loop through all of the checked elements in your CheckBoxList and output their values
                $("#<%= Checkbox_Cat_2B1.ClientID %> :checkbox:checked").each(function () {
                    // Alert the value
                    alert($(this).val());
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBoxList ID="Checkbox_Cat_2B1" runat="server" Height="350px" Width="150px">
                        <asp:ListItem Value="Cat 1">Cat 1</asp:ListItem>
                        <asp:ListItem Value="Cat 2" Selected="True">Cat 2</asp:ListItem>
                        <asp:ListItem Value="Cat 3">Cat 3</asp:ListItem>
                        <asp:ListItem Value="Cat 4">Cat 4</asp:ListItem>
                        <asp:ListItem Value="Cat 5">Cat 5</asp:ListItem>
                        <asp:ListItem Value="Cat 6">Cat 6</asp:ListItem>
                        <asp:ListItem Value="Cat 7">Cat 7</asp:ListItem>
                        <asp:ListItem Value="Cat 8">Cat 8</asp:ListItem>
        </asp:CheckBoxList>

        <button id="GetCheckedValue" onclick="return false;">Get Checked Value</button>
    </div>
    </form>
</body>
</html>

The only thing that makes this any trickier than just using a normal CheckBox input is that the ASP.NET CheckBoxList Control actually renders a table that contains a checkbox <input> element on each row (along with the Text for the specific item).
This is why you have to use jQuery to target the table itself (using the ClientID property of your CheckBoxList) and then find any checked items beneath it (using :checkbox:checked). Once you have those, you can simply loop through them and
output your values.

[RESOLVED]how to calculate totals in javascript?

hi guys,

I have created a webpage for users to buy stuff..

there are 10 items, i have placed a checkbox besides each item and a label tag with price value.. There is a textbox right at the bottom to display the total, how do i go about with the coding to get total value based on selected checkboxes? pls guide.

Use some jquery. Though controls i used are html but would work fine with asp controls.

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("input[id*=btnGO]").click(function () {
                var sum = 0;
                $("input[type=checkbox]:checked").each(function () {
                    sum = sum + Number($(this).val());
                }, null);

                $("input[id*=txtSum]").val(sum);
            });
        });
</script>
***********************************************
<input type="checkbox" value="11" />Pizza<span>11</span><br />
    <input type="checkbox" value="12" />Burger<span>12</span><br />
    <input type="checkbox" value="33" />Cake<span>33</span><br />
    <input type="checkbox" value="44" />Pastry<span>44</span><br />
    <input type="button" value="go" id="btnGO" /><br />
    <input type="text" id="txtSum" />

You can use following javascript function.

Give all check boxes same name.

Give all check box values as per pertaining label values .

try something like this

function CalculateTotal() {

    var checkBoxList = document.getElementsByName("CheckBoxName");
    var total = 0;

    for (var i = 0; i < checkBoxList.length; i++) {
       
        total = total + parseInt(checkBoxList[i].value)
    }

   textbox.text = total;
}


hope this helps.

I am trying to follow thios page:-

http://www.mcfedries.com/javascript/ordertotals.asp

what I have done is that i have used the INPUT field with name="TOTAL" 10 times; (TOTAL field displays the totqal sum)

this makes the script useless, it works only if I have exactly 1 input tag with name "TOTAL"..

is there a way out to still have 10 fields showing the total?

Hi, you can refer to the following method:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 316px;
        }
        .style3
        {
            width: 205px;
        }
    </style>
    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('.single').blur(function () {
                var sum = 0;
                for (var i = 1; i < 11; i++) {
                    sum += $('#TextBox' + i).val() * parseInt($('#Label' + i).text());
                }
                $('#TextBox11').val(sum);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table class="style1">
            <tr>
                <td class="style2">
                    Please enter quantity:</td>
                <td class="style3">
                    Price:</td>
                <td>
                    Product:</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox1" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label1" runat="server" Text="1"></asp:Label>
                </td>
                <td>
                    Product1</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox2" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label2" runat="server" Text="2"></asp:Label>
                </td>
                <td>
                    Product2</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox3" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label3" runat="server" Text="3"></asp:Label>
                </td>
                <td>
                    Product3</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox4" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label4" runat="server" Text="4"></asp:Label>
                </td>
                <td>
                    Product4</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox5" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label5" runat="server" Text="5"></asp:Label>
                </td>
                <td>
                    Product5</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox6" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label6" runat="server" Text="6"></asp:Label>
                </td>
                <td>
                    Product6</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox7" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label7" runat="server" Text="7"></asp:Label>
                </td>
                <td>
                    Product7</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox8" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label8" runat="server" Text="8"></asp:Label>
                </td>
                <td>
                    Product8</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox9" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label9" runat="server" Text="9"></asp:Label>
                </td>
                <td>
                    Product9</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:TextBox ID="TextBox10" runat="server" class="single" onkeyup="this.value=this.value.replace(/D/g,'')"></asp:TextBox>
                </td>
                <td class="style3">
                    <asp:Label ID="Label10" runat="server" Text="10"></asp:Label>
                </td>
                <td>
                    Product10</td>
            </tr>
        </table>
        Total:<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Hi,

Here are many post for calculating total-

http://delicious.com/anupdg/grandtotal

Hi,

Try this code:

function CalculateTotal() {

    var checkBoxList = document.getElementsByName("CheckBoxName");
    var total = 0;

    for (var i = 0; i < checkBoxList.length; i++) {
       if(checkBoxList[i].checked)
{
        total = total + parseInt(checkBoxList[i].value)
}
    }

   textbox.text = total;
}

[RESOLVED]chcekbox with scroll option

Iam using vs2008 .I am trying to use checkbox list with scroll option  .please help me

Whats ur issue then?
Elaborate what do u mean by scrolling, and also explain the check box list u r using
and ur requirement

Thanks for reply.

Requirement
Display set of items and check box next to each of the selection and a check box with an open text field next to it.

how to achieve the open text field in checkboxlist

hi,

I think you can use test – checkbox – textbox sequence in side a repeater.

Place ur check box in a div, and make it scrollable using overflow attributes

enable/disable textbox based on checkboxlist item value

How to enable/disable textbox based on checkboxlist item value.

Thanks,

Assuming that you are using server controls, otherwise ignore getting ClientID.

asp:CheckBoxList renders a table. So first you need to find the checkboxes from the table using checkboxlist ID and then you can attach simple click events on those checkboxes. For example:

$(document).ready(function () {
    $("#<%=chkField.Client %>").find('input[type="checkbox"]').click(function () {
        if(this.value == '0')
            $("#<%=txtField.ClientID %>").removeAttr("disabled");
        else
            $("#<%=txtField.ClientID %>").attr("disabled", "disabled");
    });
});

<asp:TextBox runat="server" ID="txtField"></asp:TextBox>
<asp:CheckBoxList runat="server" ID="chkField">
        <asp:ListItem Text="Value 1" Value="0"></asp:ListItem>
        <asp:ListItem Text="Value 2" Value="1"></asp:ListItem>
</asp:CheckBoxList>

Hi,

Can you give some more detail? Is there multiple textbox? Is there any relationship of the checkbox item and individual textbox?

Thanks for reply

In my scenario checkbox list data are loaded based on button click event(server side).

Checkbox list click events are not firing. After the page is loaded, I opened the source code to search for the code for the checklist box. There is nothing in the code not even the description.

If your JS code is in ready event, it should work for you.

$(document).ready(function () {
    $("#<%=chkField.Client ID%>").find('input[type="checkbox"]').click(function () {
        if(this.value == '0')
            $("#<%=txtField.ClientID %>").removeAttr("disabled");
        else
            $("#<%=txtField.ClientID %>").attr("disabled", "disabled");
    });
});

 <asp:DropDownList CssClass="clsComboBox" ID="ddlStatus" AutoPostBack="true" runat="server"
                                      Width="100px" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
                                  </asp:DropDownList>

<asp:CheckBoxList ID="chkField" AutoPostBack="true" TextAlign="Right" runat="server">
</asp:CheckBoxList>
<asp:TextBox ID="txtField" width= "90px" Height="20px" runat="server" />

In code behind

ddlStatus_SelectedIndexChanged iam loading the checkboxlist items.When i check the page source there is no markup for checkboxlist.

Thanks

Get checked value of checkboxlist using javascript

Hi all,

how can i get  checked value of checkboxlist using javascript

Thank you

not work with me

Hi,

You can check the following jQuery snippet!

<script type="text/javascript" src="jquery-1.5.2.min.js" ></script>
<div id="myList">
        <asp:CheckBoxList runat="server">
            <asp:ListItem Text="One" />
            <asp:ListItem Text="Two" />
            <asp:ListItem Text="Three" />
        </asp:CheckBoxList>
    </div>

    <input type="button"  value="Get List " onclick="GetList();" />
 <script type="text/javascript">
        function GetList() {
            $(':checkbox:checked', '#myList').each(function () {
                    alert($(this).val());
            });
        }
    </script>

Hope it helps u…

Thank you but i want to get the value not Text 

Hi,

Check the below code!

<div id="myList">
        <asp:CheckBoxList runat="server">
            <asp:ListItem Text="One" Value="1" />
            <asp:ListItem Text="Two" Value="2" />
            <asp:ListItem Text="Three" Value="3" />
        </asp:CheckBoxList>
    </div>

    <input type="button"  value="Get List " onclick="GetList();" />
    <span class="myclass">My Data</span>
    <script type="text/javascript">
        function GetList() {
            $(':checkbox:checked', '#myList').each(function () {
                    alert($(this).val());
            });
        }
    </script>

Hope it helps u…

Thank you but it didn’t work with me

Hi,

What’s the error you are getting?

Did you add the jQuery script file to you page?

<script type="text/javascript" src="jquery-1.5.2.min.js" ></script>

Hope it helps u…

Hello

For a checkbox, you can value "on" if the checkbox is checked. The value in its attribute does not work in this way. When you need to find if a checkbox is checked, you’ll use the name attribute or id attribute.

Hi,

Try this-

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#btn").click(function () {
                var allChecked = $("table input:checked");
                alert($.map(allChecked, function (item, index) {
                    return $(item).closest("tr").find("label").html();
                }).join(","));
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server">
    </asp:CheckBoxList>
    <input type="button" id="btn" value="Get" />
    </form>
</body>
</html>

[RESOLVED]cascading checkboxlist

Hi all,

let say i hv 2 checkboxlists which are A and B,

-Both control connected tthrough AccessSourceControl to same table.

-selection on A will filter the B result.

I now having problem in configure the data source on B since the WHERE Clause do not have IN as the checklistbox can be multiple seletion.

The Operator only consists of "Like, Contains …" which cant support the multiple selection on Control A right?

please guide.

You can pass string from combination selected checkboxlist text.

Use Stored Procedure to generate WHERE Clause

Stored procedure? can explain more?

anyone?

<asp:AccessDataSource ID="adsResult" runat="server"
        DataFile="~/App_Data/DataFeed.mdb"
        
        SelectCommand="SELECT * FROM [pc_status] WHERE ([mycolumn] in (Select [mycolumn] From dbo.Split(@[mycolumn], ',')))">
        <SelectParameters>
    
            <asp:ControlParameter ControlID="myListBox1"
                Name="mycolumn"  DefaultValue="0" PropertyName="SelectedValueList"/>
        </SelectParameters>
    </asp:AccessDataSource>

it give me error as follows…

System.Data.OleDb.OleDbException: Syntax error. in query expression ‘([mycolumn] in (Select [mycolumn] From dbo.Split(@[mycolumn], ‘,’)))’.

When the user selects in the first checklist box then you will refresh the second list based on the first selection.

Items.Add will work to read the selected values.

Hi,

Please refer to

http://forums.asp.net/p/1588730/4029248.aspx#4029248.

Any more question, please feel free to reply.

[RESOLVED]Re-arranging controls in VS 2008 versus 2005

I can re-arrange controls easily in VS 2005 by moving around controls on the form but in 2008 I have to do it from code.

Is there any way in 2008 to drag and drop controls anywhere on page without writing code.

 Thanks for the good info. But I have a different problem in VS 2008, I have a label, a checkbox and a checkboxlist in a Panel. Interestingly I can move the  checkboxlist easily inside the panel but not the label and checkbox.

 

Please help if you have any idea.

Do you have SP1 installed?