Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Selecting Multiple Items From CheckBoxList

$
0
0

i am trying to get multiple selected items from a asp:CheckBoxList but when i try to compare selected items with some value it says indexing is not allowed. here is the code and Underlined line contained errored code

      // Cat_check is a CheckBoxList in which Multiple items are selected
        for (int i = 0; i < cat_check.Items.Count; i++)
        {
            if (cat_check.SelectedItem != null)
                {
                    string columnName =cat_check.SelectedItems[i].Text;
                   var column = gvRecoed.Columns.Cast<DataControlField>()
                      .FirstOrDefault(c => c.HeaderText == columnName);
                    if (column != null) column.Visible = true;
               }
           }

the idea is that the gvRecoed(GridView) column headers will be matched with CheckBoxList items and only matched columns will be set to visible true..


Viewing all articles
Browse latest Browse all 8156


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>