Populating a checkboxlist

J

JJ297

I am able to populate the checkboxlist but need some assistance in
coding my checkboxlist1_selectedIndexChanged code behind page.

Here's my stored procedure
CREATE Procedure GetClassID

@titleid int

AS
SELECT
classifications.[description], titleclassification.classificationid

FROM
classifications inner join titleclassification on
titleclassification.classificationid =
classifications.classificationid

where titleid=@titleid
GO

Here's the code behind that's not working, please help...

Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
CheckBoxList1.SelectedIndexChanged
Dim i As Integer
Dim chkbx As CheckBoxList
For i = 0 To chkbx.Items.Count - 1

Next
if chkbx.Items.SelectedValue then

CheckBoxList1.Items(.selectedvalue = True)

Else
CheckBoxList1.Items(.selectedvalue = False)
End If

CheckBoxList1.DataBind()

End Sub
 
L

Lloyd Sheen

JJ297 said:
I am able to populate the checkboxlist but need some assistance in
coding my checkboxlist1_selectedIndexChanged code behind page.

Here's my stored procedure
CREATE Procedure GetClassID

@titleid int

AS
SELECT
classifications.[description], titleclassification.classificationid

FROM
classifications inner join titleclassification on
titleclassification.classificationid =
classifications.classificationid

where titleid=@titleid
GO

Here's the code behind that's not working, please help...

Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
CheckBoxList1.SelectedIndexChanged
Dim i As Integer
Dim chkbx As CheckBoxList
For i = 0 To chkbx.Items.Count - 1

Next
if chkbx.Items.SelectedValue then

CheckBoxList1.Items(.selectedvalue = True)

Else
CheckBoxList1.Items(.selectedvalue = False)
End If

CheckBoxList1.DataBind()

End Sub


If this is a cut and paste then you have your logic outside the for/next
loop.

Besides this I cannot see what you are attempting to accomplish.

LS
 
J

JJ297

I am able to populate the checkboxlist but need some assistance in
coding my checkboxlist1_selectedIndexChanged code behind page.
Here's my stored procedure
CREATE Procedure GetClassID
@titleid int
AS
SELECT
classifications.[description], titleclassification.classificationid
FROM
classifications inner join titleclassification on
titleclassification.classificationid =
classifications.classificationid
where titleid=@titleid
GO
Here's the code behind that's not working, please help...
Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
CheckBoxList1.SelectedIndexChanged
Dim i As Integer
Dim chkbx As CheckBoxList
For i = 0 To chkbx.Items.Count - 1
Next
if chkbx.Items.SelectedValue then

CheckBoxList1.Items(.selectedvalue = True)

Else
CheckBoxList1.Items(.selectedvalue = False)
End If
CheckBoxList1.DataBind()

End Sub


If this is a cut and paste then you have your logic outside the for/next
loop.

Besides this I cannot see what you are attempting to accomplish.

LS- Hide quoted text -

- Show quoted text -


I have a dropdown list on the page that's bind to a checkboxlist. I
want whatever title is selected (in the dropdown) to show a check next
to the item in the checkboxlist (info coming from the database). I
had the wrong checkbox sub selected it should have been the
dropdownlist1_selectedindexchanged instead.

What do I put here to bring back what's in the database and have it
checked?

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top