Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

How to assign Text and 'hidden' record ID to a checkbox control?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dan - 08 Apr 2008 16:44 GMT
I'd like to list multiple records from a database as checkboxes. I'd use
record's "Name" column for checkbox Text.  Ideally I'd like to assign a
'hidden' record's ID to checkbox so I don't need to go back to the database
to query for the ID when checkbox is clicked on.
This is similar to what can be done with DropDownList (i.e. text and value).
Is there a way to do that with checkboxes?

Thanks,
Dan
David R. Longnecker - 08 Apr 2008 17:00 GMT
If you have a list of controls, you can use the CheckBoxList control and
assign it just like a DropDownList:

           CheckBoxList cbList = new CheckBoxList();

           cbList.DataSource = GetProducts();
           cbList.DataTextField = "ProductName";
           cbList.DataValueField = "ProductID";
           cbList.DataBind();

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

> I'd like to list multiple records from a database as checkboxes. I'd
> use
[quoted text clipped - 8 lines]
> Thanks,
> Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.