Solved

VB.NET checked List Box validation

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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