ProgramWindowASP.NET

trouble with CheckBoxBoxList outside a DataList!!

I have this checkboxlist out side a Datalist below:-

<asp:checkboxlist id="chkList" AutoPostBack="True" Runat="server"
DataValueField="ProductFeatureID"
DataTextField="Feature"
OnSelectedIndexChanged="Check_Clicked"></asp:checkboxlist></

And the event that fires after when the checkBoxList is clicked
-------------------------------------------------------
Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs) Handles
chkList.SelectedIndexChanged
'print.Text = "Selected Item(s):<br><br>"
Dim i As Integer
For i = 0 To chkList.Items.Count - 1
If chkList.Items(i).Selected Then
P &= "_" & chkList.Items(i).Value
'Tested it here to print it to the screen
print.Text = P & "<br>"
End If
Next

End Sub


This is my link below in the DataList( What i want to get is the value
selected below which is ok but after selecting a checkbox i want to
append only the checbox value the user has selected but i noticed that
after the Check_Clicked fires i can't get the right values appended to
the link.
What i really want is to get the CheckBoxLixt values appended to the link below after POSTBACK which i have set in the ChecKboxList control.But it seems the Datalist doesn't get the values after postback

Any help please?

------------------------------------------------
<a href='addtocart.aspx?productid=<%#
DataBinder.Eval(Container.DataItem, "ProductID") & "&Features=" & P &
","
%>'>Add To cart</a>

Replay:trouble with CheckBoxBoxList outside a DataList!!
Try this: Create a Public or Protected function named, say, SelectedFeatures:
Code:
Protected Function SelectedFeatures() As String Dim P As String For I As Integer = 0 To chkList.Items.Count - 1 If chkList.Items(i).Selected Then P &= "_" & chkList.Items(i).Value End If Next Return P End Function
Then change the code in your DataList to this:

<a href='addtocart.aspx?productid=<%# DataBinder.Eval(Container.DataItem, "ProductID") & "&Features=" & SelectedFeatures() & "," %>'>Add To cart</a>

Replay:trouble with CheckBoxBoxList outside a DataList!!
Thx Phil for the reply. But after trying ur suggestion it still doesn't FIRE.
The thing is that after a checkbox is clicked this method fires :-

Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs) Handles
chkList.SelectedIndexChanged
'print.Text = "Selected Item(s):<br><br>"
Dim i As Integer
For i = 0 To chkList.Items.Count - 1
If chkList.Items(i).Selected Then
P &= "_" & chkList.Items(i).Value
'Tested it here to print it to the screen
print.Text = P & "<br>"
End If
Next
End Sub

And what i think is that since the CheckBoxlist is outside the DataList i can't seem to retrieve the variable after postback to append it to the QueryString.
What i did is was added the function you recommended and changed the link accordingly but didn't fire..
Is there still something 'm missing?
Thanks



ASP.NET

Session end event problem
Proper way to manage pages/forms
Problem with displaying the user control
Controlling ASPX Display
Javascript with ASP.NET
Creating buttons programatically
change headertext
Creating buttons programatically
dropdownlist problem
Blocking BACK button
Question about Email body in my asp.net
Dynamic Buttons disappearing
How to loop through rows in Datalist control?
How to loop through rows in Datalist control?
Opening a blank Infopath form from ASP.NET
Accessing Progmaticly Defined Controls Properties
Postback problem with viewstate
Postback problem with viewstate
ASP.NET Authentication & Authorization
ASP.NET (vb) NEWBIE