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

ListBoxItem checkbox not checked in edit mode

2 Answers 62 Views
Input
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 12 Aug 2010, 06:39 PM
I have a RadListBox in an editable FormTemmplate inside a RadGrid.  The ListBoxItems have checkboxes, and their data values are populated with a SQL DataSourceId.  When I select a grid row to edit, and the form populates, the ListBoxItem that matches to the data record is highlighted (selected), but its checkbox is not checked as it should be.  I've looked for a property to control this without luck.  How can I bind the ListBox such that it will check 'on' the selected ListBoxItem(s)?

This is the html:
<telerik:RadGrid ID="rgTodos" runat="server" EnableAJAX="True" AllowAutomaticUpdates="False" OnItemCommand="rgTodos_ItemCommand">
  <MasterTableView CommandItemDisplay="Bottom">
     <EditFormSettings EditFormType="Template">
        <FormTemplate>
           <table style="width: 80%" align="center">
              <telerik:RadListBox ID="listWho" runat="server" DataSourceID="dsTodoWho"
                DataTextField="wholist" DataValueField="who" Height="100px" Width="169px"
                Skin="Vista" CheckBoxes="true"  SelectedValue='<%# Bind("who") %>' 
                SelectionMode="Multiple">
              </telerik:RadListBox>

Thanks,  Dan

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 18 Aug 2010, 10:38 AM
Hello Dan,

The checkbox won't be checked by default. You could do this manually:

<telerik:RadListBox ID="listWho"
   ...
   OnDataBound="listWho_DataBound">  
</telerik:RadListBox>

protected void listWho_DataBound(object sender, EventArgs e)
{
   foreach(RadListBoxItem item in (sender as RadListBox).SelectedItems)
       item.Checked = true;
}

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan
Top achievements
Rank 2
answered on 18 Aug 2010, 04:12 PM
Daniel,

I decided to do away with the checkboxes altogether.  With the checkboxes on, when you check 'on' multiple boxes, it was not seen in the code-behind that the items were 'selected'.  Maybe there is a way to use the checkboxes with the list, but I moved on without it.  I needed to support multiple selected items and the checkboxes were just not working for me.

Thanks,
Dan
Tags
Input
Asked by
Dan
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Dan
Top achievements
Rank 2
Share this question
or