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

RadList with ComboBox

3 Answers 253 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 18 Jun 2010, 10:32 PM

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> 


3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 23 Jun 2010, 11:05 AM
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
0
Nicole
Top achievements
Rank 1
answered on 23 Jun 2010, 02:19 PM
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
0
Nikolay Rusev
Telerik team
answered on 25 Jun 2010, 12:30 PM
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
Tags
ListView
Asked by
Nicole
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Nicole
Top achievements
Rank 1
Share this question
or