473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Tick Dynamic CheckboxList boxes based on a query

Hi, I'm using VB.Net for this. My problem is that I've created a page that queries a table to populate a CheckBoxList of locations for the user to select from to be displayed elsewhere in the application. Once they've selected their options the results are saved into a seperate table, which works fine. The problem I'm having is that should the user return to the page to change their selection I can't figure out how to mark which items they've selected so they have to select all of the locations again rather than just selecting/de-selecting any extra ones they wanted. I've never used a CheckBoxList before so not sure if it's even possible when populated dynamically.
Mar 31 '08 #1
1 1201
Got it. I just added a datareader rather than a dataset.

Expand|Select|Wrap|Line Numbers
  1.       Private Sub CheckList()
  2.         Dim chkbx As CheckBoxList
  3.  
  4.         chkbx = CType(form1.FindControl("CBLocations"), CheckBoxList)
  5.  
  6.         Dim dr As SqlDataReader
  7.         Dim cmd As New SqlCommand("select_savedLocation_byUser", m_cnn)
  8.         cmd.CommandType = CommandType.StoredProcedure
  9.         cmd.Parameters.AddWithValue("@UserID", Session("UserID"))
  10.  
  11.         dr = cmd.ExecuteReader
  12.         Do While dr.Read()
  13.             Dim currentCheckBox As ListItem
  14.             currentCheckBox = chkbx.Items.FindByValue(dr("LocationID").ToString())
  15.             If currentCheckBox IsNot Nothing Then
  16.                 currentCheckBox.Selected = True
  17.             End If
  18.         Loop
  19.  
  20.     End Sub
Seems to work
Mar 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently...
3
by: Egbert | last post by:
I use a System.Web.UI.WebControls.CheckBoxList object to fill a list. I need to label groups of checkboxes in the list by Category (Determined dynamically from the database) at runtime. Is it...
2
by: jase_rw | last post by:
Hi There, Having trouble with a CheckBoxList in VB.NET. I've a CheckBoxList on a webform. I read some data from a database and try and check the appropriate boxes based on the data....
2
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic...
4
by: paul.bentley | last post by:
I am trying to get a "Date entered" box to automatically fill when a tick box = true, without success so its over to the experts for some much needed help Thanks in advance
18
by: sweeneye | last post by:
Hi, I'm basing a query on the variables used in a form. The database contains lots of problems, say with a computer and a tick box for the apropriate component like monitor, keyboard, mouse etc....
3
by: dbuchanan | last post by:
How, at rundime, do I capture the fact that the parametrized query that fills a CheckBoxList results in an empty set. When the dataset is empty the CheckBoxList does not appear. I would like to...
14
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.