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

4 posts, 0 answers
  1. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 29 May 2012 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 May 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 29 May 2012 Link to this post

    Hello Princy.

    Thank you for  helping.

    Your codes are very work fine. thank you.


  5. Aprajita
    Aprajita avatar
    2 posts
    Member since:
    Sep 2014

    Posted 25 Sep 2014 Link to this post

    Please check the pic attached..I want this kind of layout in Jquery if posssible...
Back to Top