.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

Checkbox list issues

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

Hi Experts,

I have a project table in SQL server. For each project in the table I need to generate a checkbox. So I'm dynamically generating check boxes as follows.Checkbox list is inside a panel called "pnlProject".


void fillProjects()
        DBConnect db = new DBConnect();
        DataSet ds = new DataSet();
        ds = db.getDataForgrid("SELECT project_id,project_name FROM project order BY project_name ");
        DataTable dt = ds.Tables[0];
        CheckBox chkAll = new CheckBox();
        chkAll.ID = "ChkSelectAllProject";
        chkAll.Text = "Check All";
        chkAll.Font.Italic = true;
        chkAll.Font.Bold = false;
        chkAll.AutoPostBack = true;
        chkAll.CheckedChanged += new EventHandler(chkAllProjects_CheckedChanged);
        CheckBoxList chkBox = new CheckBoxList();
        chkBox.Font.Bold = false;
        foreach (DataRow r in dt.Rows)
            string msg = r["project_name"].ToString(); 
            chkBox.Items.Add(new ListItem(msg, msg));


I have 3 questions.

1) There is a "Select All" check box in the Checkbox list. If the user selects the "Select All" I need to check all the check boxes in the list. How

View Complete Post

More Related Resource Links

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

How to Add A Scroll bar to ChecKbox List

Can any1 guide me to add scrollbar to checkboxlist Regards Chandrakant 

Customized Announcement List (Possible Permission Issues)

I am working in SharePoint 2007 with a portal site and related subsites for the various divisions within the company. I have created a custom announcement list template which is used on each subsite so that each deivision has it own announcements. I have a cotnent query web part on the main portal page that pulls all the announcements for the various subsite to the main portal page.  I am finding that only me and another individual has full rights are able to see the announcements contents (image, title and short description) via the CQWP, visitors only see the title and the rollup image of the announcement but should see a short description of the announcement. If the visitor clicks the title of the announcement they are able to see the entire contents of the announcement. I have checked the permissions on each list under the list setting and visitors all have read permissions. Any ideas on where to start troubleshooting?   Thanks,

checkbox list help!!!

How can   I make the following code shorter and more efficient.  Goal:  I want to loop through the check box list for all true values.   I want to get the check list item and complare with database value then check the box.                For Each xList As ListItem In cblGroupDiningOptions.Items                        If xList.Text = "Meals_List" Then                            If eContentItems.Meals_List = True Then                                xList.Selected = True                           End If                        End If                 &n

List of SSRS Issues

How do I find list of issues with SSRS?

Object reference not set to an instance of an object in Nested Repeater Control of CheckBox List con

 if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
                Repeater rptsub = (Repeater)item.FindControl("rptsub");
                CheckBoxList Chksub = (CheckBoxList)rptsub.FindControl("Chksub");
                Label lblsubroot = (Label)rptsub.FindControl("lblsubroot");
                DataRowView row = (DataRowView)e.Item.DataItem;
                RootId = Convert.ToInt32(row["IdApplication"].ToString());
                MetadataPermissions metadataPermissions = new MetadataPermissions(); ;
                DataSet rptRootValues = new DataSet();
                rptRootValues = metadataPermissions.GetrptSubMenus(RootId);
                DataRow[] drows = rptRootValues.Tables[0].Select("IdApplicationroot = " + row["IdApplication"].ToString());
                foreach (DataRow chkpermsns in drows)
                   ListItem li = new ListItem(chkpermsns["PermissionName"].ToString());


<asp:Repeater ID="rptroot" runat="server" OnItemDataBound="rptroot_ItemDataBound">

Multiple issues with dropdown list controls not working correctly


I am using WSS 3.0 and SharePoint Designer.  I have modified one of the items in my NewForm page so that I have a filtered lookup using a spdatasource. The filter works great, but my issue is that I can't seem to save the users selection back to the list itself.

Issue when using an ASP.NET dropdown list
I am able to bind the filtered spdatasource to an ASP.NET dropdown list control, however the item that is selected in the dropdown list is not being saved back to the list.  I am guessing that this is because the dropdown list itself is not tied directly to the appropriate list item, but... I can't seem to figure out how or where to do this.  I don't see anything in the data properties box in SharePoint Designer that allows me to tie the data back to the list itself.  Maybe I am just overlooking it somewhere?

Issue when using the native SharePoint Data View DropDownList with a filtered spdatasource
When I select "Data Fields..." on the dropdown control I get the Change Data Bindings dialog box.  From here I can select a data field to save the value back to (which resolves the issue noted for the asp.net control) and I can select my spdatasource, but... the display text and value fields below that never populate.  Thus, the dropdown list is empty when the user is filling ou

Filtering with Multiple selections (Checkbox list control)

I have a scenario where there is a large list of 2000+ items, these items each have a name associated to it.

I now need to be able to filter this list by selecting the names from a Checkbox list, the problem is I cannot figure out how to get it to work when multiple values are selected.

The current setup is Using a DVWP to display the items a Datasource control of all the names and then the ASP.NET Checkbox list control to act as a filter

Can anyone help?

using a checkbox list and Table Valued Parameters


I have a checkboxlist that gets all all the items from a look up table. The user is going to go to the list, check certail items and insert the checkboxid, the value (0 or 1),  and the userid  into a table valued paramater using a stored procedure. I have the user defined table type created but thats about it. Any body out there have any hints.

update dynamic checkbox list


Hi there .. on page load I fill a repeater with checkboxes. I use a separate tablelist (subcatID & userID) to check if chkbox is checked or not.

On pageload and works fine (according boxes are checked):

For i = 0 To rptFavorites.Items.Count - 1
                Dim subcatID As Label = DirectCast(rptFavorites.Items(i).FindControl("lblSubcatID"), Label)
                Dim available As Label = DirectCast(rptFavorites.Items(i).FindControl("lblAvailable"), Label)
                Dim chksubcat As CheckBox = DirectCast(rptFavorites.Items(i).FindControl("chkSubcat"), CheckBox)

                Dim conn3 As New SqlConnection(ConfigurationManager.ConnectionStrings("VCConnString").ConnectionString)
                Dim cmd3 As New Data.SqlClient.SqlCommand("Select * From tbl_interest where userID=@userID and subcategory=@subcategory", conn3)
                cmd3.Parameters.AddWithValue("@userID", "28")
                cmd3.Parameters.AddWithValue("@subcategory", subcatID.Text)
                Dim myReader3 As Data.SqlClient.SqlDataReader
                myReader3 = cmd3.ExecuteReader()
                If myReader3.Read() Then
                    chksubcat.Checked = True
                    available.Text = "Y"

MVC2 Convention for Many-to-Many Relationship and Checkbox List?


I have a many-to-many relationship in my database (and Entity Framework Model) as follows:


Can anyone tell me the convention for creating a list of checkboxes for Data Admin that my users can select to fill the USER_DATA_ADMIN table?

(kind of new to MVC2)


List Web Part Issues in Site Template

I have about 10 list web parts each list with a custom content type and custom columns and a default view set. I am displaying these web parts on the site's default page. Everything looks great. WHEN I save the site as a template and create a NEW site from the template, the list web parts do not automatically grab the default views from the libraries, instead they just pull in the default Title column and thats it. I have to manually modify each web part to grab the default view. Is there a way around this? I don't understand why it cannot grab the default view automatically.



Client-side checkbox list validator?


I've looked at these:



but these both work server-side (unless I'm missing something). I had hopes for the second one because it embeds javascript.

I have other validators on the page, and I want to show everything at once.  But the other ones are client-side, while the two I tried don't show the error message until the page posts back.

How do I store a list of checkbox choices in the DB most efficiently?


I'm not expecting a full solution here (unless you really want to), just some tips and pointers.

I have a User table and an Area table. The User table has userID, userName etc., and the Area table has areaID, areaName etc.
I'm binding the list of Areas to a checkboxlist where the user MUST choose between 1-3 options. I'm using a stored procedure to update the DB.

Is there a common solution to this problem that I haven't found?

I have thought about saving it as a comma separated string in a field in the user table. This looks like a temporary and ugly solution though, do you think?

A nicer solution would be to create a UserArea table where I save the ID's as foreign keys from areaID and userID. But I don't know how to write this stored procedure where I update and insert the choices made.
This way would also help me when I need to get statistics, plus it's moer scalable, I think.

Any help is greatly appreciated!


accessing checkbox list from with in edit item template.


Protected Sub dsEmployeesByDepartments_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
        'Determine which checkboxes have been checked
        Dim selectedDepartmentIDs As New List(Of String)
        For Each li As ListItem In CategoryList.Items
            If li.Selected Then

Custom document library list template issues with custom content type


Either I don't know what SharePoint is doing or I don't know what I'm doing (or both, which is more likely).

I'm attempting to create a Custom Document Library template with a custom content type association (Custom Document), all using a feature. When I create
a document library based on the installed template, the content type association is there. However, when I click on New Custom Document, the template.dotx does not reflect the Custom Document content type association. The Word document information panel does not show any Custom Document content type properties (like Title and Comments).

Here are the steps I've taken:

1. Create the feature.xml with element manifests of contentType.xml and CustomDocumentLibrary.xml
2. Create the contentType.xml (Custom Document) with an additional field reference for Comments
3. Create the CustomDocumentLibrary.xml for the list template
4. Create a Custom Document Library subfolder that contains the same files that are in the 12\TEMPLATE\FEATURES\DocumentLibrary\doclib folder.
5. Edit the schema.xml to use the new content type and field reference
6. Deploy and activate the feature
7. Create a new "Custom Document Library"
8. Go to Custom Document Library Settings and verify the Custom Document content type is being used
9. Click on New Custom D

How to create a dynamic list of checkbox controls in Infopath


I am relatively new to sharepoint, and since I do not yet have a proper development environment in my current contract, I have had to attempt to produce solutions to various line of business problems using Nintex and Infopath alone.  They are working on getting one created for me but i still can't believe microsoft make you purchase a whole other sharepoint server licence unless you think developing directly on the live server is a good idea, but I digress, thats not the issue I need assistance with.

The current issue I am trying to find a solution for, or atleast the right way to approach, is the creation of a simple form where the user can check off a register of daily tasks completed and submit the form back to sharepoint from a tablet PC.  Each submission is to create a new entry in the DailyRegister list with a handful of other fields like who, where, when, etc.

That is the easy part that I was able to produce with relative ease, but where it gets tricky is they want the list of tasks to be dynamic. 

i.e. A separate sharepoint list that will just hold the list of currently relevant tasks to be included in the form for that day.  Effectively using a 3rd list as the relational reference table between the DailyRegister list and the AvailableTasks list.

I am planning to create the AvailableTasks list to look something like:

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