.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Checkboxlist !!!

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

checkboxlist textbox from a data transfer,
I want those people in the textbox before the deletion.


The second update, not deletion textbox

View Complete Post

More Related Resource Links

Dynamic Checkboxlist exception when adding to Panel when using Master Page


In essence, I am creating Dynamic Checkboxlist controls and adding them to a Panel.  It works well when I do not have a Master Page configure to this webpage. Once I have a masterpage congifured.. I get a "Object Reference not set to instance of object" error on the Panel_Control.Controls.Add(Checkboxlistnew) line:

protected void Page_PreInit(object sender, EventArgs e)
        XML OXML = new XML();
        alistChkBoxLabels = OXML.XMLTransform("C:\\Documents and Settings\..\\Config_new.xml", "config_options/check_box/applications/app/@name");
        int count = 1;
        alistCheckisFacility = new ArrayList();
        alIDTracker = new ArrayList();
        while (count <= alistChkBoxLabels.Count)

            Checkboxlistnew = new CheckBoxList();
            Checkboxlistnew.ID = count.ToString();
            Checkboxlistnew.Items.Add(new ListItem(alistChkBoxLabels[count - 1].ToString(), alistChkBoxLabels[count - 1].ToString()));

            String sAppName = alistChkBoxLabels[count - 1].ToString().Trim();

            alistCheckisFacility = OXML.XMLTransform("C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2005\\WebSites\\User_Trial\\Config_new

Trying to get Roles to populate a checkboxlist based on tutorial and having issues.


I have been using the following tutorial and had to convert the code to C# for my project, now i cant get the code to work, im getting red line under the word "in" in the UpdateRolesFromList,
i tried to add a datasource on page load for the checkboxlist like so RoleList.DataSource = PopulateRoleList(User.Identity.Name.ToString());

and gives me error saying cannot implictly convert type 'void' to 'object'


What am i missing, that when i load the page or even do a search it never displays the checkbox list as it shows in the tutorial?

        protected void Page_Load(object sender, EventArgs e)

        public void PopulateRoleList(string userName)
            string[] roleNames = null;
            string roleName = null;
            roleNames = Roles.GetAllRoles();
            foreach (string roleName_loopVariable in roleNames)
                roleName = r

how to get the text of selected checkbox from asp.net checkboxlist control using jquery


I have asp.net checkboxlist control that bounded to a data source so the number of items in the control are different from one to to another time.

I have this function:

     $('#<%=chkListGroups.ClientID %> input:checkbox:checked').siblings('label').text();

this function will return all texts for all selected items in the control as a one string.

 I'm looking for a way that when I check a check box from the ckeckboxlist control will return only last checked checkbox.

this code :

$('#<%=chkListGroups.ClientID %> input:checkbox:checked').last().siblings('label').text(); 

returns last checked item for example if I checked second will return
second item then when I checked fifth item will return fifth item but
if now when I check third item will return fifth item so it is always
returning last item checked in the list and I'm looking to

Please advice me how to do this using jquery.

checkboxlist full post back problem is association with PopupControlExtender


I have used a checkboxlist in association with PopupControlExtender. All the items are inside the update panel. I used the server side SelectedIndex changed event of checkbox list for another purpose.  But it cause full post back while checking the check box item. The update panel doent make any sense here.

        <asp:ScriptManager ID="Scriptmanager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">

CheckBoxList embedded in FormView InsertItemTemplate problem


I've searched hi/lo and found many similar posts but those answers aren't working for me.

I've got a FormView, in an UpdatePanel.  In the FormView's EditItemTemplate and InsertItemTemplate I'm using both a CheckBox and a CheckBoxList.  To present the data I databind in the code behind, (but then have to iterate to mark selected).  There I cast the sender as CheckBoxList in the OnPreRender event and use that object. 

The problem is retrieval.  I'm trying to access the user's entries when they submit by using the cast.  It is working fine for the CheckBox, but for the CheckBoxList the resulting checkboxlist object doesn't have any items. 

Here, both active and roles are created (they're not 'null') and active has the expected 'name' and 'selected' values, but roles has an item count = 0 and the for loop isn't entered.


            CheckBox active = ((CheckBox)Emp_Form.FindControl("cbActive"));

            CheckBoxList roles = (CheckBoxList)Emp_Form.FindControl("UsrRoles");

            foreach (ListItem role in roles.Items)
                // do stuff


Is there another way to cast a checkboxlist?  Any help would b

CheckBoxList in GridView

I have a checkboxlist control in a template column in a gridview.  I would like to be able to have a link button for "select all" and a link button for "unselect" on each row.  I know how to use jquery to select all of the check boxes in the gridview but  I want this to only check the checkboxes on this row.  How would you do this?   Thanks     

Problem getting values next to each other from two separate CheckBoxList controls

Hi, I am using three CheckBoxList controls in ASP.NET Wizard control. CheckBoxList controls: <asp:CheckBoxList ID="cblLondonDates" runat="server" DataSourceID="SqlDataSource1" DataTextField="ShowDate" DataTextFormatString="{0:G}" DataValueField="ShowDate" ForeColor="#333333" CssClass="ShowDateMargin"></asp:CheckBoxList> <asp:CheckBoxList ID="cblSingleL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size8" DataValueField="size8" ForeColor="#333333"> </asp:CheckBoxList> <asp:CheckBoxList ID="cblHalfL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size6" DataValueField="size6" ForeColor="#333333"></asp:CheckBoxList>   cblLondonDates chackboxlist control shows dates generated from SQL table. cblSingleL an cblHalfL show table sizes. On ASP page they come up as following: 12/03/2011(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 03/03/2012(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 05/10/2010(checkboxlist-ID="cblLo

VWD 2010 does not seem to recognise checkboxlist

 I added a new control to a page: <asp:checkboxlist id="checkFaults" runat="server">                                       <asp:listitem id="option1" runat="server" value="Driver" />                                       <asp:listitem id="option2" runat="server" value="Cable" />                                       <asp:listitem id="option3" runat="server" value="Light" />                                     </asp:checkboxlist> Then I tried to reference it in my code page: if (checkFaults.Items[0].Selected)  

CheckBoxList client-side validation

How can I validate on client side if a CheckBoxList has at least one item? (is not empty)


It works on local but on Live does not. SelectedIndexChanged does not fire On local machine its totally fine. selected change does not fire on Live but if u click a bit close to checkbox it works on Live as well.   <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>  <asp:CheckBoxList ID="chkLicense" runat="server" AutoPostBack="True" CssClass="lblFont" onselectedindexchanged="chkLicense_SelectedIndexChanged" TabIndex="2">  </asp:CheckBoxList> </ContentTemplate> </asp:UpdatePanel>    protected void chkLicense_SelectedIndexChanged(object sender, EventArgs e)        {             if (chkLicense.SelectedItem == null)                return;                        if (chkLicense.SelectedItem.Text == "C+E (Class 1)")            {                chkLicense.Items[0].Selected = true;       

CheckBoxList in UpdatePanel won't change values

Hello all.  I have a CheckBoxList that contains the days of the week.  If I use standard asp.net with AutoPostBack = true, everything works fine.  However, I would like to not have post backs everytime a user selects a day, so I'm trying to get the control to update using Atlas.  Here is the code (note: I put in the asteriks to bypass the filters on this website):  <*atlas:UpdatePanel ID="validDaysUpdatePanel" runat="server" Mode="Always"> <*ContentTemplate> <*asp:CheckBoxList ID="cblValidDays" runat="server" CssClass="inputfields" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="cblValidDays_SelectedIndexChanged" > <*asp:ListItem Text="All" Selected="True"><*/asp:ListItem> <*asp:ListItem Text="Sun" Value="1"><*/asp:ListItem> <*asp:ListItem Text="Mon" Value="2"><*/asp:ListItem> <*asp:ListItem Text="Wed" Value="4"><*/asp:ListItem> <*asp:ListItem Text="Thu" Value="5"><*/asp:ListItem> <*asp:ListItem Text="Fri" Value="6"><*/asp:ListItem> <*asp:ListItem Text="Sat" Value="7"><*/asp:ListItem> <*/asp:CheckBoxList> <*/ContentTemplate> <*Triggers> <*atlas:ControlEventTrigger ControlID="cblValidDays" EventName="SelectedIndexChanged" /> <*/Triggers> <*/atlas:Upd

Get Value of CheckBoxList using JavaScript

hi all,I am trying to get the value of a CheckBoxList ( ASp control) with the help of Javascript.Here value means the datavalue not text. the main problem with this control is that it does not show the value on the client side and that is why I cant fetch the value.Please help me out with this problem, and if this is not possible then it ia very big problem with the Control.Thankx All.

CheckBoxList's Datasource is null

Hi, I am trying to get solution for below problem. Please help.Page 1: To add a record in to DB. At this page, as per the user requests , few controls will be added to the page from server side code.one of them is checkbox list.and when user is requesting to save data, its going to the DB.Everything is fine upto now.Page 2: To edit the record which is entered from page no 1. When user requests to edit the record entered at page no 1, i'm redirecting user to this update page, with record id, and generating the required controls to show the values.Now the main problem is :When page is loading first time , I m creating the required controls and then assigning the values to them to edit.but after that at each postback, the value of datasource of checkboxlist is becoming null, same case is with the label control.but the value of textbox is same, it is not becoming empty at each postback.In code :   In code i have created two method to generate controls.1st is : to create new controls, and to assign values to them2nd is : to regenerate the controls at each postback, with the same IDs, but not assigning any value here.I think viewstate will reload the values of respective controls, if IDs are same.So , what should  i do here?

CheckBoxList - save values to SQL

Hi, I have a checkboxlist on a c# page where when a box is checked it saves its value in the following format to a textbox 1,2,3, etc...  String values = ""; for (int i=0; i< cbl.Items.Count; i++) { if(cbl.Items[i].Selected) { values += cbl.Items[i].Value + ","; } } values = values.TrimEnd(','); This works ok however the problem is i want to be able to audit the values i save in the DB. For example i may want to do a count how many times 1 appears or 2 etc.. What is the best way to do this? Thanks 

get rid of native dots, in the checkboxlist

Hello:<asp:CheckBoxList ID="chkAccessRights" TabIndex="8" runat="server" Width="194px"> <asp:ListItem Text="Change Users" Value="ChangeUser"></asp:ListItem> <asp:ListItem Text="User Profile page" Value="UserProfilePage"></asp:ListItem> </asp:CheckBoxList> The code above ia a CheckBoxList, So the items appear as a list one below the other, with a chekbox on it's left and a dot on the left of the checkbox. Would it be possible to get rid of <ul> native dots, in the checkboxlist? If so please help with syntax. I hope I was clear with the question. Thanks for your support.    

Passing checkboxlist variables and returning one row at a time

I am designing a page for my students to practice their Latin vocabulary.  I am having two problems with the design: 1) working with checkboxes, and 2) display one returned row at a time. 1) First, students select from CheckListBox1 those parts of speech (nouns, verbs, adjectives, etc.) they want to review, and then they click Button1 ("Submit"), which fires off a SELECT statement against a table named CoreVocab in a SQLEXPRESS database.  How do I pass each selected part of speech from CheckListBox1 as a variable into the WHERE statement when the user clicks Button1? Do I place this code in the Button1_Click on the .cs page? 2)  Ideally, the table returns the first row and Button1 changes to "Next," which the student then clicks to see the next Latin word.  How do I get the Repeater table to show only one row at time until the Next button is clicked? And how do I get the same button to executed two functions (fire off the SELECT statement and then show the next row)?  For what it's worth, I'm using the SqlDataReader command, since data will only be retrieved, not modified. Thanks. I'm new at this.  But I really need to do something for my suffering students. Oliphant

checkboxlist unchecking with javascript


i have a checkboxlist in detailsview .On unchecking the first item,all the items are get unchecked with javascript.but in item updating event of detailsview the items showing the status checked==true  .any ideas?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend