RadList with ComboBox

4 posts, 0 answers
  1. Nicole
    Nicole avatar
    2 posts
    Member since:
    Jun 2010

    Posted 18 Jun 2010 Link to this post

    Hi

    I have a RadListView with a RadComboBox in the fieldset itemtemplate, and the RadComboBox has a CheckBox ItemTemplate.

    What I’m need to do is to change the text of the first item in my combobox and hide the checkbox.

    It works fine if I have only one combobox but I need this in a ListView.
    Thanks,
    Nicole

     protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)  
     {  
     
                RadComboBox cmbColores = (RadComboBox)e.Item.FindControl("cbmColores1");  
     
                DataTable dt = CargarCombos();  
     
                //Add Item  
                dt.Rows.Add(-1, "");  
     
                DataView dv = new DataView();  
                dv = dt.DefaultView;  
                dv.Sort = "NombreCompleto";  
                DataTable dt1 = dv.ToTable();  
     
                cmbColores.DataSource = dt1;  
                cmbColores.DataTextField = "NombreCompleto";  
                cmbColores.DataValueField = "SKUID";  
                cmbColores.DataBind();  
                 //change text: first item combobox
                cmbColores.FindItemByValue("-1").Text = " -- Seleccione --";  
                RadComboBoxItem item = cmbColores.FindItemByValue("-1");  
                CheckBox chk = (CheckBox)item.FindControl("chk1");  
                 //first item combobox
                chk.Visible = false;  
     

     

     <telerik:RadListView ID="RadListView1" Width="100%" AllowPaging="true" runat="server" 
                        ItemPlaceholderID="ProductsHolder" DataKeyNames="SKUID" OnNeedDataSource="RadListView1_NeedDataSource" 
                        OnItemDataBound="RadListView1_ItemDataBound" OnItemCommand="RadListView1_ItemCommand">  
                        <ItemTemplate> 
                            <fieldset> 
     
                            <telerik:RadComboBox ID="cbmColores1" runat="server" Skin="Windows7" Width="180px" 
                              EmptyMessage="Color..." LoadingMessage="Cargando..." OnClientDropDownClosed="onDropDownClosing" 
                             AutoPostBack="False">  
                                                <ItemTemplate> 
                                                    <div onclick="StopPropagation(event)">  
                                                        <asp:CheckBox runat="server" ID="chk1" Checked="false" /> 
                                                        <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1">  
                                                         <%# DataBinder.Eval(Container.DataItem, "NombreCompleto")%> 
                                                        </asp:Label> 
                                                    </div> 
                                                </ItemTemplate> 
                                            </telerik:RadComboBox> 
                             </fieldset> 
                        </ItemTemplate> 
                        <LayoutTemplate> 
                            <fieldset id="RadListView1" > 
                             </fieldset> 
                        </LayoutTemplate> 
                    </telerik:RadListView> 


  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 23 Jun 2010 Link to this post

    Hello Nicole,

    I have tested your code locally and seems to be working just fine. Please check the attachment to this post.

    Regards,
    Nikolay
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nicole
    Nicole avatar
    2 posts
    Member since:
    Jun 2010

    Posted 23 Jun 2010 Link to this post

    Hi, thanks for your help.
    I'm getting this error: Compiler Error Message: CS1525: Invalid expression term '>' , (I think is the Framework Version).

    Line 44:     protected void RadListView1_NeedDataSource(object sender,RadListViewNeedDataSourceEventArgs e)    
    Line 45:     {
    Line 46: RadListView1.DataSource = Enumerable.Range(0, 2).Select(i => i);Line 47:     }
    Line 48: }
    Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.3053
    for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727

    Also when I test it in my page the dropdownlist has values but the checkbox of the first item isn't visible=false.

    Nicole
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 25 Jun 2010 Link to this post

    Hello Nicole,

    Simply bind RadGrid to collection. It really doesn't matter in this particular case. In the demo I am using .NET 3.5 Enumerable.
    For example:
    protected void RadListView1_NeedDataSource(object sender,RadListViewNeedDataSourceEventArgs e)    
    {
            RadListView1.DataSource = new object[] { 1,2,3  };  
    }

    You will see that first item checkbox is hidden.

    Regards,
    Nikolay
    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
Back to Top