DataBinding: 'Telerik.Web.UI.RadComboBoxItem' does not contain a property with the name 'Normal_IconPath'

13 posts, 1 answers
  1. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 13 Jul 2011 Link to this post

    hi,

    I have two combo box

    the first one has auto post back true so when selected index changed it fills the second combo box

                        <table>
                            <tr>
                                <td>
                                    <asp:Label ID="lblDevGroups" runat="server" Text="Groups"></asp:Label></td>
                                <td>
                                        <telerik:RadComboBox ID="ddlDevGroups" runat="server" Width="200px" MarkFirstMatch="true" AutoPostBack="true" />
                                    </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblDevices" runat="server" Text="Devices" Visible="False"></asp:Label></td>
                                <td>
                                    <telerik:RadComboBox ID="ddlDevices" runat="server" Width="200px" MarkFirstMatch="true" AutoPostBack="false" Visible="false">
                                        <ItemTemplate>   
                                        <table style="border-bottom: 1px dotted #EFEFEF; margin-bottom: 10px; font-size: 11px;" width="98%">     
                                            <tr>       
                                                <td>         
                                                    <img src='<%# DataBinder.Eval(Container, "Normal_IconPath")%>' alt="" />       
                                                </td>       
                                                <td>
                                                     <%#DataBinder.Eval(Container, "Serial_No")%>
                                                    (<%#DataBinder.Eval(Container, "Device_Name")%>)
                                                </td>     
                                            </tr>   
                                        </table>
                                        </ItemTemplate>
                                    </telerik:RadComboBox>
                                    </td>
                                <td>
                                    <asp:Button ID="btnEditDevices" runat="server" Text="Edit" Visible="False" /></td>
                            </tr>
                        </table>

    the ddlDevGroubs (the first combo box) selected index changed event is:

            ddlDevices.Items.Clear()
            Dim strGroupID As String = ddlDevGroups.SelectedValue
            If Not strGroupID = "" Then

                Dim strSQLDevices As String = "Select ds.ID, ds.Device_ID, ds.Device_Name, ds.Serial_No, ds.Icon, dc.Normal_IconPath  from CTS_DeviceSettings ds inner join dbo.CTS_DeviceIcons dc on ds.Icon = dc.id where ds.group_ID=" & strGroupID
                Dim dsDevices As DataSet = clsDB.getData(strSQLDevices)

                If Not dsDevices Is Nothing Then
                    If dsDevices.Tables(0).Rows.Count > 0 Then

                        Dim dtDevices As DataTable = dsDevices.Tables(0)
                        'dtDevices.Columns.Add("DevIDName")

                        'Dim i As Integer = 0
                        'For i = 0 To dtDevices.Rows.Count - 1
                        '    Dim strDevName As String

                        '    If IsDBNull(dtDevices.Rows(i)("Device_Name")) Then
                        '        strDevName = ""
                        '    Else
                        '        strDevName = dtDevices.Rows(i)("Device_Name")
                        '    End If

                        '    Dim strDevID As String = dtDevices.Rows(i)("Device_ID")

                        '    Dim strDevSerialNo As String = ""

                        '    If Not IsDBNull(dtDevices.Rows(i)("Serial_No")) Then
                        '        strDevSerialNo = dtDevices.Rows(i)("Serial_No")
                        '    Else
                        '        strDevSerialNo = ""
                        '    End If

                        '    If Not strDevName = "" Then
                        '        dtDevices.Rows(i)("DevIDName") = strDevSerialNo & " (" & strDevName & ")"
                        '    Else
                        '        dtDevices.Rows(i)("DevIDName") = strDevSerialNo
                        '    End If

                        'Next

                        For Each row As DataRow In dtDevices.Rows
                            row("Normal_IconPath") = Page.ResolveClientUrl(row("Normal_IconPath").ToString())
                        Next

                        ddlDevices.DataSource = dtDevices
                        'ddlDevices.DataTextField = "DevIDName"
                        'ddlDevices.DataValueField = "ID"
                        ddlDevices.DataBind()
                        lblMessage.Visible = False
                        lblDevices.Visible = True
                        ddlDevices.Visible = True
                        ddlDevices.Visible = True
                        btnEditDevices.Visible = True
                        btnEditDevices.Visible = True
                        lblDevices.Visible = True
                    Else
                        'No Device Records
                        lblMessage.Text = "No Devices have been Found"
                        lblMessage.Visible = True
                        pnlInfo.Visible = False
                        ddlDevices.Visible = False
                        btnEditDevices.Visible = False
                        lblDevices.Visible = False
                        clsLog.WriteNoRecords("/Members/Devices/Configuration.aspx", strSQLDevices)
                    End If

                Else
                    'error Devices
                    lblMessage.Text = "Error While retriving Devices information"
                    lblMessage.Visible = True
                    clsLog.WriteSQLError("/Members/Devices/Configuration.aspx", strSQLDevices)
                End If
            Else
                lblMessage.Text = "Please select a group"
                lblMessage.Visible = True
                ddlDevices.Visible = False
                btnEditDevices.Visible = False
                lblDevices.Visible = False
            End If

    now after all I got this error:

    DataBinding: 'Telerik.Web.UI.RadComboBoxItem' does not contain a property with the name 'Normal_IconPath'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: DataBinding: 'Telerik.Web.UI.RadComboBoxItem' does not contain a property with the name 'Normal_IconPath'.

    Source Error:

    Line 90:                                         <tr>       
    Line 91:                                             <td>         
    Line 92:                                                 <img src='<%# DataBinder.Eval(Container, "Normal_IconPath")%>' alt="" />       
    Line 93:                                             </td>       
    Line 94:                                             <td><%#DataBinder.Eval(Container, "Serial_No")%>

    so any help please?
  2. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 13 Jul 2011 Link to this post

    I tried this:

                                    <telerik:RadComboBox ID="ddlDevices" runat="server" Width="230px" MarkFirstMatch="true" AutoPostBack="false" Visible="false" CssClass="qsfexAlignedInput">
                                        <ItemTemplate>   
                                        <table style="border-bottom: 1px dotted #EFEFEF; margin-bottom: 10px; font-size: 11px;" width="98%">     
                                            <tr>       
                                                <td>         
                                                    <img src='<%#eval("Normal_IconPath")%>' alt="" />       
                                                </td>       
                                                <td>
                                                     <%#Eval("Serial_No")%>
                                                    (<%#Eval("Device_Name")%>)
                                                </td>     
                                            </tr>   
                                        </table>
                                        </ItemTemplate> 
                                    </telerik:RadComboBox>

    somehow, it works but with problems,

    I can't select an item, I keep getting System.Data.DataRowView, even more than this, when I move my mouse over the item of combobox, it should be highlighted but I dont get it highlighted !!

    and can I set the ID (data table column) to ddlDevices.DataValueField from <ItemTemplate> ?

    so anyone can help please?
  3. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 14 Jul 2011 Link to this post

    anyone can help here?
  4. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 15 Jul 2011 Link to this post

    this is the problem of telerik support, when you have a problem or ask a question you will be answered after one month :(
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 18 Jul 2011 Link to this post

    Hi Khaled,

    The reason for the experienced behavior is the following. When you have binding expression you should either use the data bound to some of the properties of the RadCombobox's item or get information from the DataItem field. In your case the '<%# DataBinder.Eval(Container, "Normal_IconPath") is looking for a property named "Normal_IconPath". Of course the RadComboBox has no such property, so you could use the another approach, to get this value from the DataItem. This way you expression should be the following: <%# DataBinder.Eval(Container.DataItem, "Normal_IconPath"). When this approach is used as you have noticed the text in the input is System.Data.DataRowView, because this value is not bound to the RadComboBoxItem, so you should use custom attributes, which is the suitable scenario for this situation.

    Please have a look at the following help articles here and here, giving detailed information the custom attributes and how to use binding expression.

    Regards,
    Dimitar Terziev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 18 Jul 2011 Link to this post

    why this line of code:

    <%# DataBinder.Eval(Container"Attributes('DisplayName')") %>


    is producing syntax error in aspx page?
  7. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 18 Jul 2011 Link to this post

    Error    100    Comma, ')', or a valid expression continuation expected.  
    Error    134    Overload resolution failed because no accessible 'Eval' accepts this number of arguments.
    Error    135    Comma, ')', or a valid expression continuation expected.
  8. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 21 Jul 2011 Link to this post

    Hi Khaled,

    The reason for the experienced behavior is due to the fact that the syntax should be the following:
    <%# DataBinder.Eval(Container, "Attributes('DisplayName')") %>
     
    You are missing a comma after the Container. As I'm seeing this is a mistake in our documentation as well so I'll fix it as soon as possible.

    Please accept my apologies of the inconvenience caused.

    Kind regards,
    Dimitar Terziev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  9. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 22 Jul 2011 Link to this post

    thanks very much,

    but still I cant select the item from rad combo box (see attached image please)
    here is my code:

    <telerik:RadComboBox ID="ddlDevices" runat="server" Width="200px" MarkFirstMatch="true" AutoPostBack="false" Visible="false">
                                        <ItemTemplate>   
                                        <table style="border-bottom: 1px dotted #EFEFEF; margin-bottom: 10px; font-size: 11px;" width="98%">     
                                            <tr>       
                                                <td>         
                                                    <img src='<%# DataBinder.Eval(Container, "Attributes('Normal_IconPath')") %>' alt="" />       
                                                </td>       
                                                <td>
                                                     <%#DataBinder.Eval(Container, "Attributes('Serial_No')")%>
                                                    (<%#DataBinder.Eval(Container, "Attributes('Device_Name')")%>)
                                                </td>     
                                            </tr>   
                                        </table>
                                        </ItemTemplate>
                                    </telerik:RadComboBox>


                        ddlDevices.DataSource = dtDevices
                        ddlDevices.DataBind()

                        Dim i As Integer = 0
                        While i < ddlDevices.Items.Count
                            Dim Normal_IconPath As String = dtDevices.Rows(i)("Normal_IconPath").ToString()
                            Dim Serial_No As String = dtDevices.Rows(i)("Serial_No").ToString()
                            Dim Device_Name As String = dtDevices.Rows(i)("Device_Name").ToString()
                            ddlDevices.Items(i).Attributes("Normal_IconPath") = Normal_IconPath
                            ddlDevices.Items(i).Attributes("Serial_No") = Serial_No
                            ddlDevices.Items(i).Attributes("Device_Name") = Device_Name
                            ddlDevices.Items(i).DataBind()
                            i = i + 1
                        End While
  10. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 22 Jul 2011 Link to this post

    Hello Khaled Jendi,

    Please set the DataTextField and DataValueField properties of the RadComboBox (for example in this way):
    <telerik:RadComboBox ID="ddlDevices" runat="server"
    Width="200px" MarkFirstMatch="true" AutoPostBack="false" Visible="false"
    DataTextField = "Device_Name" , DataValueField="Device_ID">

    Regards,
    Kalina
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  11. khaled jendi
    khaled jendi avatar
    64 posts
    Member since:
    Mar 2010

    Posted 22 Jul 2011 Link to this post

    ok, I found the problem and I have solved it ;)

    thank you very much
  12. GARY078
    GARY078 avatar
    11 posts
    Member since:
    Jun 2012

    Posted 11 Oct 2012 Link to this post

    Hi,

    I'm also using Custom Attributes to bind a multi column comboBox and I'm having trouble "selecting" a RadComboBoxItem.

    What would be the custom attribute approach to this method...

    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() ;
    e.Item.Value = ((DataRowView)e.Item.DataItem)["CustomerID"].ToString(); 

    }

    Clearly the items are not DataItems, so how would I go about setting e.Item.Text and e.Item.Value properties?
  13. Nencho
    Admin
    Nencho avatar
    1822 posts

    Posted 15 Oct 2012 Link to this post

    Hello  Gary,

    Could you elaborate a bit more on what exactly is the problem that you are facing and what do you mean by "I'm having trouble "selecting" a RadComboBoxItem".?

    Greetings,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top