0

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?

1 Answer 1

1

You need to use Value property.

string selectedProducts = string.Empty;
foreach (ListItem chk in productsList.Items) {
    if (chk.Selected == true) {
        selectedProducts += chk.Value+ ", ";
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

@PhiterFernandes I did but there was not simple solution given like Leopard did.
But I'm sure google would give you the simplest of the solutions, which is the simple usage of Value
@PhiterFernandes you can search on google. There were solution which was large lines of codes & no value hint given any of them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.