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

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

12 Answers 693 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
khaled jendi
Top achievements
Rank 1
khaled jendi asked on 13 Jul 2011, 09:24 AM
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?

12 Answers, 1 is accepted

Sort by
0
khaled jendi
Top achievements
Rank 1
answered on 13 Jul 2011, 10:25 AM
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?
0
khaled jendi
Top achievements
Rank 1
answered on 14 Jul 2011, 09:38 PM
anyone can help here?
0
khaled jendi
Top achievements
Rank 1
answered on 15 Jul 2011, 07:31 AM
this is the problem of telerik support, when you have a problem or ask a question you will be answered after one month :(
0
Dimitar Terziev
Telerik team
answered on 18 Jul 2011, 09:28 AM
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!

0
khaled jendi
Top achievements
Rank 1
answered on 18 Jul 2011, 04:15 PM
why this line of code:

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


is producing syntax error in aspx page?
0
khaled jendi
Top achievements
Rank 1
answered on 18 Jul 2011, 04:16 PM
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.
0
Dimitar Terziev
Telerik team
answered on 21 Jul 2011, 10:55 AM
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!

0
khaled jendi
Top achievements
Rank 1
answered on 22 Jul 2011, 03:26 PM
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
0
Accepted
Kalina
Telerik team
answered on 22 Jul 2011, 03:37 PM
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!

0
khaled jendi
Top achievements
Rank 1
answered on 22 Jul 2011, 04:08 PM
ok, I found the problem and I have solved it ;)

thank you very much
0
GARY078
Top achievements
Rank 1
answered on 11 Oct 2012, 09:52 AM
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?
0
Nencho
Telerik team
answered on 15 Oct 2012, 02:25 PM
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.
Tags
ComboBox
Asked by
khaled jendi
Top achievements
Rank 1
Answers by
khaled jendi
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Kalina
Telerik team
GARY078
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or