Selecting the items in a CheckBoxList control that are already selected

Simple problem here.  I’ve not used a CheckBoxList control in an ASP.NET application before (ASP.NET 3.5 in this case), and now I need to.  Databinding it to the source to populate the items of the list is easy.  However, selecting those items which are already stored in the database; I’m not sure how I can do that with databinding. So the question is, how do I databind the items in the CheckBoxList which reflect the items already selected in the database, in this case in a resolution table between the data items table and the lookup table, so that I get what’s in the resolution table?  Ultimately, I’ll need to save the changes the user enters when they update which items in the CheckBoxList they want select, so I’ll need to do that, too.  I’m assuming that this can all be done through databinding, but I’m not sure how that is done. Or is the only way to do this is to iterate through the resolution table and set the items in the CheckBoxList, in code? 

 


Doctor Who
0
Doctor
4/26/2009 11:52:08 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
873 Views

Similar Articles

[PageSpeed] 8

Check this post out.  http://forums.asp.net/t/1414074.aspx

Essentially you will databind the control.  After its databound loop through all the listitems and set whether they are checked or not.

 


View Brenden Kehren's profile on LinkedIn
Remember to mark as answer if this post answered your question.
0
b471code3
4/27/2009 2:26:43 AM

I thought that might be the answer.  I must admit that I'm a bit surprised that there isn't a way of doing it strictly through databinding.  Microsoft seems so keen on the idea of databinding, that I would have thought they'd have provided a way for this to happen.  But oh well, thank you very much for the link to other articles describing how to handle the CheckBoxList and data from resolution tables

 


Doctor Who
0
Doctor
4/27/2009 3:42:18 AM
Reply:

Similar Artilces:

Selecting already selected date in Calendar control
Greetings,  I have a calendar control inside an UpdatePanel. As indicated in the documentation (and verified by testing), the SelectionChanged event is triggered only if the selected date is changed. That is, it does not trigger if the user clicks on the already selected date.  However, clicking on the already selected date does cause an async postback of the UpdatePanel that contains the calendar.  So, my question -- how can I determine that the cause of the postback was the user clicking a second time on the calendar control? There does not appear to be a ...

Responding to selected control items in Datalist control
 Hi ladies and gentlemen . I am having a kinda wierd problem. I am using a datalist control bound to a database and I have implamented the following code.              <asp:DataList ID="MainCategory" runat="server" SelectedIndex="1" style="line-height: normal; text-align: left" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" RepeatColumns="3" ShowFooter="False" ShowHeader="False" Width="335px"  Font-Size="Medium" Height="58px" OnItemComman...

How to display the more than one row with items and buttons in gridview control. when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in g
Hi,when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in gridview.Here i would like to change this way "when i click more than one category at same time. it should be display selected item and button."For example: if i have to select Fruits, Apples from categories.  it should be display like 1st "row have Fruits and In 2nd row have Apples and button" in gridview.the button have some event.How can i do it? Please can anyone answer me.With kind requestThanks your query is very raw..can u details it out...Pl...

Pre-Selecting Items in a CheckBoxList Control
 Is there an asp 2.0 way to: Pre-Select Items in a CheckBoxList Controlusing a separate table to see what should be selected.I've read: Pre-Selecting Items in a CheckBoxList Controlhttp://aspnet.4guysfromrolla.com/articles/050703-1.aspxBut this is all C#, can anyone give me some VB? nevermind, it's like: here is the asp.net 2.0 VB way to do it:        Dim dr As Data.OleDb.OleDbDataReader        dr = objCommand.ExecuteReader(CommandBehavior.Default)        Dim item As ListItem        Dim sVal As String ...

Pre-Selecting Items in a CheckBoxList Control
Hi I found an ASP.NET article, and I'm trying to recreate the scenario in the article, but I'm running into problems.  The article is located here: http://aspnet.4guysfromrolla.com/articles/050703-1.aspx   Basically, I have a CheckBoxList that I need to bind some data to, and then I need specific items to show as selected based on a query's condition.  The data loads in the CheckBox successfully, but no selections are made.  Any ideas?  Here's the code I'm working with: My CheckBoxList: <asp:CheckBoxList ID="cblInterest" runa...

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

how to populate a dropdownlist control and update the selected item in a gridview control
Hi friends help me with this ... Requirement: 1) i want to populate a dropdownlist(ddl) in a gridview when clicking the edit button of a perticular row by using gridview events and also update the selected item of the ddl to the database. 2) also i don't want to use sqldatasource controls i.e. we should take the help of only gridview events 3) DropDownList will be populated fom TableB: Actions taken: In page_load while binding the grid i m getting the error: Cannot perform '=' operation on System.Int32 and System.String  my fields and datatypes are as follows...

Validate if more than two items selected in CheckBoxList Control
How can this be accomplished? I tried, if checkboxlist1.items(3).selected > 3 then'code hereend if and a few other variations, but no luck.Please help. You need to loop through the items list and check         For Each item As ListItem In CheckBoxList1.Items               If item.Selected Then                 Response.Write(String.Format("The {0} is selected.<BR>", item.Text))             ...

select control in a repeater control
Hi I have a repeater control which data are selected that way:  Strsql = "SELECT T_PRODUIT.NO_PRODUIT, T_PRODUIT.UNITE, T_PRODUIT.NO_CATEGORIE, T_PRODUIT.NO_CSBE,T_PRODUIT.NOUVEAU,T_PRODUIT.ID_PRODUIT, " & _ "CASE WHEN IMAGE IS NULL THEN 'Aucun.gif' ELSE IMAGE END AS IMAGE1, T_PRODUIT.NOM, " & _ "T_PRODUIT.DESCR, T_PRODUIT.DETAIL,T_FOURNISSEUR_PRODUIT.NO_FOURNISSEUR_PRODUIT, T_FOURNISSEUR_PRODUIT.PRIX, T_FOURNISSEUR_PRODUIT.PRIX_LISTE, " & _ "T_FOURNISSEUR.NOM as FNOM, T_FOURNISSEUR.NO_F...

Enable/disable requiredfieldvalidator control of textbox depending on selection of item in radiobuttonlist control
Hi,   I have a webform with a radiobuttonlist control. 1.The user has to select one option from the radiobuttonlist control.   ie.The values are  a ,b , c ,Other. So I have used a requiredfield validator control for the radiobuttonlist control. 2.But if the user selects the option " Other",then there is a textbox control next to it.The user has to enter some value in the textbox control.So I have a requiredfield  validator control for the textbox . 3.But how to enable the requiredfield control for the textbox only if the user selects the option &qu...

Why is the select saying selected after an item is selected?
This was a whitelisting issue due to a software upgrade at hostgator..  Nothing wrong with my code..Scot King SEO Software Tool | Search Engine Optimization"Get your page rank high"  huh? It is smart to put your question in the body and not just in the title. Have no idea what your question is or if it even a question.Eric Pascarello.com | Twitter epascarello | LinkedIn use thisddl.options[ddl.selectedIndex].selected = false; //Clear the selection ddl.options[1].selected = trueMAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Sit...

dropdwon list - user must select an item other than -SELECT ONE-, before submitting the page
In my asp.net 2.0 page, I placed a dropdwon listthe list is filled from the datatabase in formload() event, and I added one more entry -SELECT ONE- This select one will be displayed when the page loads. Ok fine.I want the user to select an item other than -SELECT ONE-, before submitting the page,ex: list shows country names, user should select a country name. Which validator control is to be used for this, and how can i code this.any idea    hi use required field validator control On - Initial value of -Requiredfieldvalidator control has "--Select one--"that should...

Menu Item, Selected Item, and Site Map controls
Ok no code here, actually looking for some.  I've created a Menu and when I click on the link to go to another page, even if I set the Static and Dynamic Selected Item to another style (changing a color, whatever) it doesn't change.  Do I have to do this programmatically?  If so, can someone give me some sample code to use? Also I've noticed the SelectedItem works fine when I bind the menu to a Site Map, however I haven't been able to set up the Site Map to not have the first layer of navigation.  Example:  If you have a website that has a "Home...

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

Web resources about - Selecting the items in a CheckBoxList control that are already selected - asp.net.presentation-controls

APNS Pusher, debug your push notification app - Coders Grid
Coders Grid your best development resources collections site Menu Skip to content Resource web development design stuffs guideline coding mobile ...

.NET sample code - developer Fusion
Discover the very latest .NET sample code Out of the box, the ASP.NET list controls (CheckBoxList, RadioButtonList, DropDownList) only support ...

ConditionalRequiredTextValidator Control
The ConditionalRequiredTextValidator control allows you to specify a CheckBox, RadioButton, CheckBoxList, RadioButtonList, DropDownList, or ListBox ...

Sports-Gazer - About Us
Sports-Gazer is an application for ranking and rating sports teams. It also can project scores for upcoming games. Certain parts of this application ...

Layar 3.0 mobile augmented reality browser launched
Layar, the world’s first augmented reality (AR) browser…

ASP.NET 4 and Visual Studio 2010 Web Development Overview : The Official Microsoft ASP.NET Site
This document provides an overview of many of the new features for ASP.NET that are included in the.NET Framework 4 and in Visual Studio 2010. ...

Gaiaware - Gaia Ajax
Home Samples Download Free Trial Buy from $195 Login Download Free Trial ASP.NET Done Right 6 reasons to use Gaia Ajax? 40 UI controls 10 aspects/behaviors ...

compass - Coders Grid
Coders Grid your best development resources collections site Menu Skip to content Resource web development design stuffs guideline coding mobile ...

APNS Pusher, debug your push notification app
Coders Grid your best development resources collections site Menu Skip to content Resource web development design stuffs guideline coding mobile ...

Buttons.css, a css library makes buttons beautiful - Coders Grid
Coders Grid your best development resources collections site Menu Skip to content Resource web development design stuffs guideline coding mobile ...

Resources last updated: 11/24/2015 2:17:10 AM