Solved

VB.NET checked List Box validation

Posted on 2003-12-04
3
332 Views
Last Modified: 2008-03-17
I am writing a simple data entry form and want to use the checked list box. Each box may have more than 2 items in the collection but only one should be selectable at a time. This value should also update the bound SQL server field with the name of the item selected from the collection. I need help with the syntax to make this happen!

what I have so far:

Private Sub clbDeadorAlive_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles clbDeadorAlive.ItemCheck

End Sub

Dead or Alive being the items in the collection, There are also CLB's with 4 or more items in the collection.

0
Comment
Question by:Dalexan
  • 2
3 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 9881169
Why don't you use RadioButtonList
if you choose that the only thing that you will have to do is to check if the an item of this list is selected
this could be done by two ways
use RequireFieldValidator and set it's property ControlToValidate to this list
you can write your own validator in your page_load

B..G
0
 

Author Comment

by:Dalexan
ID: 9885829
Can you type out the syntax for the RadioButtonList control.
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 125 total points
ID: 9887349
if you will bind the radiobuttonlist from your code behind

Dim rbList as RadiobuttonList
rbList.DataSource = yourdataset
rbListDataTextField = yourcolumnfromyourdataset
rbListDataValueField = yourcolumnfromyourdataset
rbList.DataBind()

this will bind a dataset to your radiobuttonlist

the add to your form
Dim reqValid as RequiredFieldValidator
reqValid.ControlToValidate = rbList;
reqValid.EnableClientScript = True

this will give you that if you not select an item from the radiobuttonlist the form will not be submited

if you will add these controls in design mode
from the tool box drag and drop Radiobuttonlist object to your form
in Properties window of this web control define DataSource , rbListDataTextField and rbListDataValueField

after that drag and drop RequiredFieldValidator web control and in the properties window set ControlToValidate to the radiobuttonlist id

B..G
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question