Couldn't check multiple checkbox items

2 posts, 0 answers
  1. Mppp
    Mppp avatar
    1 posts
    Member since:
    Jul 2014

    Posted 06 Aug 2014 Link to this post

    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;
                                }
                            }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Aug 2014 in reply to Mppp Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top