Solved

VB.NET checked List Box validation

Posted on 2003-12-04
3
330 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now