adding Checkbox in RadPanelBar Items

4 posts, 0 answers
  1. Suresh Kannan
    Suresh Kannan avatar
    14 posts
    Member since:
    Oct 2009

    Posted 14 Oct 2009 Link to this post

    Hello,

       I m new to Telerik, wants to add the all sub items (LEVEL '1') as checkbox using RadPanelBar, also need to handle the Checkbox events when i am checking.

    Sample code:

    <

    telerik:RadPanelBar runat="server" ID="RdPanelCategories" ExpandMode="SingleExpandedItem"

     

     

    EnableViewState="false" DataValueField="CategoryID" DataTextField="CategoryName"

     

     

    DataFieldID="CategoryID" DataFieldParentID="ParentCategoryID" DataSourceID="SqlDSCategories"

     

     

    OnClientItemClicked="rdPanelCategories_OnClientItemClicked"

     

     

    OnItemDataBound="rdPanelCategories_OnItemDataBound">

    if i put the below code, adding add items in twise one is normal text and another is checkbox including Root, but i dont want that...

     

    <ItemTemplate>

    <asp:CheckBox ID="chktest" runat="server" Text=<%#Bind("CategoryName") %> />

    </ItemTemplate>


    Regards,
    Suresh Kannan P

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

    Posted 14 Oct 2009 Link to this post

    Hi Suresh,

    I tried adding the CheckBox control for the panelitems in level 1 from code behind in ItemDataBound event as shown below. Give a try with this code.

    C#:
     
    protected void RadPanelBar1_ItemDataBound(object sender, Telerik.Web.UI.RadPanelBarEventArgs e) 
        RadPanelItem item = (RadPanelItem)e.Item; 
        int level = item.Level; 
        if (level == 1) 
        { 
            CheckBox chk = new CheckBox(); 
            chk.CheckedChanged += new EventHandler(chk_CheckedChanged); 
            item.Controls.Add(chk); 
        } 
    void chk_CheckedChanged(object sender, EventArgs e) 
         

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Suresh Kannan
    Suresh Kannan avatar
    14 posts
    Member since:
    Oct 2009

    Posted 14 Oct 2009 Link to this post

    Great, Thanks for reply.

    It's added, but how can i link the check box and subitems ? it's showing like
    "SubItem1"
    "checkbox"
    "SubItem2"
    "checkbox"

    ...my question is how to link "subitem1" with "checkbox", "subitem2" with another "checkbox".....

    When i click the checkbox i want to capture the value of the equalat subitem value ??

    can you suggest me !!


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

    Posted 01 Dec 2009 Link to this post

    Hi suresh,

    Give a try with following code in order to access the item text when clicking the checkbox.

    cs:
     
        void chk_CheckedChanged(object sender, EventArgs e) 
        { 
            CheckBox chk = (CheckBox)sender; 
            RadPanelItem item = (RadPanelItem)chk.NamingContainer; 
            Response.Write(item.Text); 
        } 

    -Shinu.
Back to Top