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>
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