Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2004, 06:00 PM
Registered User
 
Join Date: Dec 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Jeremy Goldman
Default inserting Checkboxlist input into database

Getting a little annoyed. I've successfully bound a checkboxlist control to a sql server table to populate the list - now I want to take the user's selections and store each checkbox in the list's input in a different field in the database. No idea how to do this, and I can't find any samples online. I'm pretty sure I need to write some looping code using "For each", but don't know how to implement..anyone with ideas?

 
Old February 13th, 2004, 09:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You get the left paddle and I'll get the right.

http://p2p.wrox.com/topic.asp?TOPIC_ID=9689


 
Old February 13th, 2004, 10:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Here is an example straight from MSDN. This code applies to "ListBox, DropDownList, CheckBoxList, and RadioButtonList". I think it is what you are looking for:

' Visual Basic
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Dim msg As String
   Dim li As ListItem
   msg = ""
   For Each li In ListBox1.Items
      If li.Selected = True Then
         msg = msg & "<BR>" & li.Text & " selected."
      End If
   Next
   Label1.Text = msg
End Sub


It is under "Determining the Selection in a List Web Server Control". This should give you a base to work from. Replace the code between the "If" statement with your code to update the fields in your database.

Hope this helps.

J
 
Old February 13th, 2004, 01:55 PM
Registered User
 
Join Date: Dec 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Jeremy Goldman
Default

Thanks - just need to figure out the database code, which'll be a lil' tricky, since the order of the checkboxlist is going to change repeatedly - but that's a good start! Appreciated.

Quote:
quote:Originally posted by stu9820
 You get the left paddle and I'll get the right.

http://p2p.wrox.com/topic.asp?TOPIC_ID=9689







Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting an input box in asp.net mungur Visual Web Developer 2008 1 November 11th, 2008 08:58 AM
Help in inserting to Database?? Hannibal Pro JSP 0 March 14th, 2006 07:11 AM
Posting checkboxlist parameters into database rayncarnation ASP.NET 1.0 and 1.1 Basics 0 October 6th, 2005 09:59 AM
Inserting into database ZiqXx C# 6 July 5th, 2004 04:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.