user1865039
user1865039

Reputation: 131

How to dynamiccally bind checkboxlist in gridview using backend Query

For normally checkboxlist i using these binding is work, but how to bind in gridview for each row dynamically.

        List<string> availableItems = new List<string> { "Item1", "Item2", "Item3", "Item4", "Item5" };
        List<string> selectedItems = new List<string> { "Item1", "Item3", "Item4", "Item6" };

        // add available items to checkboxlist control
        foreach (string item in availableItems)
            chkItems.Items.Add(new ListItem(item));

        // check pre-selected items
        var query = from ListItem listItem in chkItems.Items
                    join item in selectedItems
                    on listItem.Value equals item
                    select listItem;

        foreach (ListItem listItem in query)
            listItem.Selected = true;

Upvotes: 0

Views: 657

Answers (1)

Louisth
Louisth

Reputation: 726

When in RadGrid ItemCreated using the FindControl to find the checkBoxList and bind on it.

Upvotes: 1

Related Questions