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

Multi column Combo Box

1 Answer 257 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 04 Jul 2013, 09:35 AM
Hello

I have created Multicolumn RAD Combo box and it is working fine but once user select any value it is displaying single column, is it possible to show multipal values as a text after user selects specific option. please find attached images, when it is displaying the list at that time it is showing the multipal columns in this example it is showing Template group,Effective Date,Expiry Date but once user select specific value then it is just showing Single column Template group. how to display multipal columns for selected value.


1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jul 2013, 09:35 AM
Hello,

Please try with below code snippet.



protected void RadComboBox1_DataBound(object sender, EventArgs e)
{
    //set the initial footer label
    ((Literal)RadComboBox1.Footer.FindControl("RadComboItemsCount")).Text = Convert.ToString(RadComboBox1.Items.Count);
}
 
protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
 
    DataTable dt = new DataTable();
 
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("ContactName", typeof(string));
    dt.Columns.Add("City", typeof(string));
    dt.Columns.Add("ContactTitle", typeof(string));
 
    dt.Rows.Add(1, "name1", "city", "title");
    dt.Rows.Add(2, "name2", "city", "title");
    dt.Rows.Add(3, "name3", "city", "title");
    dt.Rows.Add(4, "name4", "city", "title");
    dt.Rows.Add(5, "name5", "city", "title");
 
 
 
    RadComboBox1.DataSource = dt;
    RadComboBox1.DataBind();
}
 
protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
    //set the Text and Value property of every item
    //here you can set any other properties like Enabled, ToolTip, Visible, etc.
    e.Item.Text = ((DataRowView)e.Item.DataItem)["ContactName"].ToString() + " "
        + ((DataRowView)e.Item.DataItem)["City"].ToString() + " "
        + ((DataRowView)e.Item.DataItem)["ContactTitle"].ToString();
    e.Item.Value = ((DataRowView)e.Item.DataItem)["ID"].ToString();
}


<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
       <script type="text/javascript">
           function UpdateItemCountField(sender, args) {
               //Set the footer text.
               sender.get_dropDownElement().lastChild.innerHTML = "A total of " + sender.get_items().get_count() + " items";
           }
       </script>
   </telerik:RadScriptBlock>

<telerik:RadComboBox runat="server" ID="RadComboBox1" Height="190px" Width="420px"
    MarkFirstMatch="true" EnableLoadOnDemand="true" HighlightTemplatedItems="true"
    OnClientItemsRequested="UpdateItemCountField" OnDataBound="RadComboBox1_DataBound"
    OnItemDataBound="RadComboBox1_ItemDataBound" OnItemsRequested="RadComboBox1_ItemsRequested"
    Label="Grid-like multi-column:">
    <HeaderTemplate>
        <ul>
            <li class="col1">Contact Name</li>
            <li class="col2">City</li>
            <li class="col3">Title</li>
        </ul>
    </HeaderTemplate>
    <ItemTemplate>
        <ul>
            <li class="col1">
                <%# DataBinder.Eval(Container.DataItem, "ContactName") %></li>
            <li class="col2">
                <%# DataBinder.Eval(Container.DataItem, "City") %></li>
            <li class="col3">
                <%# DataBinder.Eval(Container.DataItem, "ContactTitle") %></li>
        </ul>
    </ItemTemplate>
    <FooterTemplate>
        A total of
        <asp:Literal runat="server" ID="RadComboItemsCount" />
        items
    </FooterTemplate>
</telerik:RadComboBox>


Thanks,
Jayesh Goyani
Tags
ComboBox
Asked by
Rahul
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or