This is a migrated thread and some comments may be shown as answers.

Couldn't check multiple checkbox items

1 Answer 68 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mppp
Top achievements
Rank 1
Mppp asked on 07 Aug 2014, 04:56 AM
I have a saved the multiple checked items into my database, when I retrieve out the records, it only checked one item in the listbox instead of multiple. I have also verified that the records returned in the datatable contains 3 records.

aspx:
 <telerik:RadListBox ID="lbxDevelopmentComponent" SelectionMode="Multiple" runat="server" OnClientItemChecked="OnClientItemChecked"
                                        CheckBoxes="true" DataTextField="Text" DataValueField="Value" Width="500px" Height="150px">
                                    </telerik:RadListBox>

.cs:
var dtDevelopmentComponent = _objSqlManager.ExecuteSQL(sqlDevelopmentComponent.ToString(), paramDevelopmentComponent);

                        if (dtDevelopmentComponent.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtDevelopmentComponent.Rows.Count; i++)
                            {
                                RadListBoxItem item = lbxDevelopmentComponent.FindItemByText(dtDevelopmentComponent.Rows[0]["DEVELOPMENT_COMPONENT_NAME"].ToString());
                                if (item != null)
                                    item.Checked = true;
                            }
                        }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Aug 2014, 10:27 AM
Hi,

Please do the following modification in your code snippet which works fine at my end.

C#:
...
if
(dtDevelopmentComponent.Rows.Count > 0)
{
    foreach (RadListBoxItem item in lbxDevelopmentComponent.Items)
    {
        for (int i = 0; i < dtDevelopmentComponent.Rows.Count; i++)
        {
            if (item.Text == dtDevelopmentComponent.Rows[i]["OrderID"].ToString())
                if (item != null)
                    item.Checked = true;
        }
    }
}
...

Thanks,
Shinu.
Tags
ListBox
Asked by
Mppp
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or