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

2 posts, 0 answers
  1. kapil
    kapil avatar
    1 posts
    Member since:
    Aug 2010

    Posted 17 Aug 2010 Link to this post

    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

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Sep 2010 Link to this post

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