?
Solved

VB.NET checked List Box validation

Posted on 2003-12-04
3
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

719 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