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

ListBox items checkboxes are not getting checked inside the Rad Grid in Edit mode

1 Answer 175 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
kapil
Top achievements
Rank 1
kapil asked on 17 Aug 2010, 06:16 PM
Hi All ,

I have a Rad Grid which has the Rad Edit Functionality. When I am clicking on the Edit. It gets the Id and should checked the list box items (List box is an ascx file)as per the id . It is going through the process and and making the ckeckbox items checked in the Code but not showing up checked. I would really appreciate, if someone has the solution or sugesstions for this.

Here is the code that I am using ;-

 

For Each grdItem As Telerik.Web.UI.GridItem In GridAssignmentRelocationAssistance.Items

 

 

    For Each selectedFilesItem In selectedFiles

 

 

        If selectedFilesItem = GridAssignmentRelocationAssistance.MasterTableView.DataKeyValues(grdItem.ItemIndex)   
        (GridAssignmentRelocationAssistance.MasterTableView.DataKeyNames(2)).ToString()
Then

 

 

            Dim selectBox As CheckBox = grdItem.FindControl("chkRelocationAssistanceFiles")

 

            selectBox.Checked =

True

 

 

        End If

 

 

    Next

 

 

Next

Thanks,
Kapil

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2010, 06:54 AM
Hello Kapil,

Check out the following sample code which shows how to select a CheckBox in ListBox (which is inside the UserControl) when the grid is in edit mode.

Mark Up:(ASCX)

<telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="false">
    <Items>
        <telerik:RadListBoxItem Text="aaa" />
    </Items>
    <ItemTemplate >
        <asp:CheckBox ID="chkRelocationAssistanceFiles" runat="server" Text="a" />
    </ItemTemplate>
</telerik:RadListBox>

ASPX:
<Columns>
   . . . . . . . . . . . . . . . . .
   <telerik:GridTemplateColumn>
      <EditItemTemplate>
         <uc1:ListBoxUserControl ID="ListBoxUserControl1" runat="server" />
      </EditItemTemplate>
   </telerik:GridTemplateColumn>
   . . . . . . . . . . . . . . . . . .
</Columns>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
  {
      if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
      {
          GridEditFormItem editItem = (GridEditFormItem)e.Item;
          UserControl uc = (UserControl)editItem.FindControl("ListBoxUserControl1");
          RadListBox listBox = (RadListBox)uc.FindControl("RadListBox1");
          CheckBox chk = (CheckBox)listBox.Items[0].FindControl("chkRelocationAssistanceFiles");// accessing the first ListBoxItem(CheckBox)
          chk.Checked = true;
      }
  }

-Shinu.
Tags
ListBox
Asked by
kapil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or