Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Loading CheckBoxList

Reply
Thread Tools

Loading CheckBoxList

 
 
Andy G
Guest
Posts: n/a
 
      06-23-2006
I have a checkBoxList control on a page that I want to load from a table.
After it is loaded from the table I would like to check the certain boxes
that are selected in the table.

This is kindof what I have going here, I have a datareader loading the
initial check list and then I am looping through a dataset to try to 'check'
the boxes. I think I'll need a way to combine these two to make this work.

Any help is greatly appreciated. If you have a website with info a link
would be great too.

Dim str As String = "SELECT PAY_MTHD_ID, PAY_MTHD FROM
dbo.tblCONF_PAY_MTHD_LIST;"

Dim myCmd As SqlCommand = New SqlCommand(str, conn)

Dim drPay As SqlDataReader

Dim dsPay As DataSet

Dim i As Integer

Try

conn.Open()

drPay = myCmd.ExecuteReader(CommandBehavior.CloseConnectio n)

chkPayTypes.Items.Clear()

chkPayTypes.DataValueField = "PAY_MTHD_ID"

chkPayTypes.DataTextField = "PAY_MTHD"

chkPayTypes.DataSource = drPay

chkPayTypes.DataBind()



Dim daPay As New SqlDataAdapter("SELECT CONF_ID, PAY_MTHD_ID, ALLOW " & _

"FROM dbo.tblCONF_PMT_ALLOW " & _

"WHERE CONF_ID = " & myID, conn)

dsPay = New DataSet

daPay.Fill(dsPay, "Payment")

For i = 0 To dsPay.Tables("Payment").Rows.Count - 1

Select Case dsPay.Tables("Payment").Rows(i).Item("PAY_MTHD_ID" )

Case 1

If dsPay.Tables("Payment").Rows(i).Item("ALLOW") Then

chkPayTypes.Items(0).Selected = True

End If

Case 2

If dsPay.Tables("Payment").Rows(i).Item("ALLOW") Then

chkPayTypes.Items(1).Selected = True

End If

Case 3

If dsPay.Tables("Payment").Rows(i).Item("ALLOW") Then

chkPayTypes.Items(2).Selected = True

End If

End Select

Next

chkPayTypes.DataSource = dsPay

chkPayTypes.DataBind()


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
loading image -> detect when image is done loading edfialk Javascript 0 05-10-2007 07:28 PM
[OT] Is loading the second Java application faster than loading the first? David Segall Java 2 01-02-2007 04:41 PM
Image loading using javascript. Handling timeouts and parrallel loading under IE zborisau@gmail.com Javascript 4 08-28-2005 02:02 PM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM



Advertisments