Reputation: 973
I have checkboxlist in which Item of checkbox & it's value is different. I need to show users item but when it gets submitted it should take selectedItems value. How it can be done?
string selectedProducts = string.Empty;
foreach (ListItem chk in productsList.Items) {
if (chk.Selected == true) {
selectedProducts += chk.Text + ", ";
}
}
With above code I am getting selectedItem. How can I get selectedItems values?
Upvotes: 0
Views: 250
Reputation: 14624
You need to use Value
property.
string selectedProducts = string.Empty;
foreach (ListItem chk in productsList.Items) {
if (chk.Selected == true) {
selectedProducts += chk.Value+ ", ";
}
}
Upvotes: 1