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

Multi-column Combobox Problem (can't selected item)

3 Answers 85 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
shunman
Top achievements
Rank 1
shunman asked on 29 May 2012, 09:04 AM
Hello Telerik Team.

I faced with a problem about Multi-column Combobox selection.
I tried combobox binding like below.  It doesn't work fine.

Selected combobox item is not shown on the box.
I want to select located 2nd item. but still shown "System.Data.DataRowView" text

please let me know how can i  solve this problem

thanks you.
<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadControlsWebApp1._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadComboBox runat="server" ID="RadComboBoxProduct" TabIndex="13" Width="100%"
        HighlightTemplatedItems="true" EnableEmbeddedSkins="true" >
        <headertemplate>
                                        <ul>
                                            <li class="col1">Product </li>
                                            <li class="col2">Product Status </li>
                                        </ul>
                                    </headertemplate>
        <itemtemplate>
                                        <ul>
                                            <li class="col1">
                                                <asp:Label runat="server" ID="RadComboBoxItemProduct"></asp:Label>
                                            </li>
                                            <li class="col2">
                                                <asp:Label runat="server" ID="RadComboBoxItemProductStatus"></asp:Label>
                                            </li>
                                        </ul>
                                    </itemtemplate>
    </telerik:RadComboBox>
    </form>
</body>
</html>

Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim datatable As New DataTable()
 
        datatable.Columns.Add("ProductName")
        datatable.Columns.Add("CodeName")
        datatable.Columns.Add("FirmProductNo")
 
 
        datatable.Rows.Add("11396", "ddddd", "Inhouse")
        datatable.Rows.Add("23742", "ereeee", "Died")
        datatable.Rows.Add("2302", "oewjhf", "Dead")
        datatable.Rows.Add("0928", "ddddd", "Cutted")
 
        RadComboBoxProduct.DataSource = datatable
        RadComboBoxProduct.DataBind()
    End Sub
 
    Protected Sub RadComboBoxProduct_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles RadComboBoxProduct.ItemDataBound
 
        Dim labelProduct = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProduct"), Label)
        Dim labelProductStatus = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProductStatus"), Label)
 
        labelProduct.Text = e.Item.DataItem("ProductName")
        labelProductStatus.Text = e.Item.DataItem("CodeName")
 
        e.Item.Value = e.Item.DataItem("FirmProductNo")
    End Sub

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 May 2012, 10:20 AM
Hi Shunman,

After inspecting your code I found that you are not setting e.Item.Text of RadComboBox. Please try the following code snippet in ItemDataBound event of RadComboBox.

VB:
Protected Sub RadComboBoxProduct_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadComboBoxItemEventArgs)
    Dim labelProduct As Label = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProduct"), Label)
    Dim labelProductStatus As Label = DirectCast(RadComboBoxProduct.Items(e.Item.Index).FindControl("RadComboBoxItemProductStatus"), Label)
    labelProduct.Text = DirectCast(e.Item.DataItem, DataRowView)("ProductName").ToString()
    labelProductStatus.Text = DirectCast(e.Item.DataItem, DataRowView)("CodeName").ToString()
    e.Item.Value = DirectCast(e.Item.DataItem, DataRowView)("FirmProductNo").ToString()
    e.Item.Text = DirectCast(e.Item.DataItem, DataRowView)("CodeName").ToString()
End Sub

Hope this helps.

Thanks,
Princy.
0
shunman
Top achievements
Rank 1
answered on 29 May 2012, 11:22 AM
Hello Princy.

Thank you for  helping.

Your codes are very work fine. thank you.


0
Aprajita
Top achievements
Rank 1
answered on 25 Sep 2014, 10:15 AM
Please check the pic attached..I want this kind of layout in Jquery if posssible...
Tags
ComboBox
Asked by
shunman
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
shunman
Top achievements
Rank 1
Aprajita
Top achievements
Rank 1
Share this question
or