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

DataBinding: 'System.String' does not contain a proerpy with the name...

0 Answers 259 Views
Grid
This is a migrated thread and some comments may be shown as answers.
justin
Top achievements
Rank 1
justin asked on 27 Jun 2012, 02:45 PM
Need help here. This grid has 2 records being displayed. If I edit the first record everything works fine. If I edit the second record I get this debug message:

This only happens if I have ListDataMember="ReportName"

HttpException was unhandled by user code
DataBinding: 'System.String' does not contain a property with the name 'ReportName'

here is the item databound sub, Getting the error on ReportNameddList.Databind()
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then
        Dim GridRow As GridEditableItem = e.Item
        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim editMan As GridEditManager = editedItem.EditManager
 
 
        ' this covers the report format field priming
        Dim editor As GridDropDownListColumnEditor = CType(editMan.GetColumnEditor("ddReportFormat"), GridDropDownListColumnEditor)
 
        Dim ReportFormatddList As DropDownList = editor.DropDownListControl
        ReportFormatddList.Items.Insert(0, New ListItem("Excel", "Excel"))
        ReportFormatddList.Items.Insert(1, New ListItem("PDF", "PDF"))
        ReportFormatddList.Items.Insert(2, New ListItem("HTML4.0", "HTML4.0"))
        ReportFormatddList.DataBind()
 
        'select the correct record
        Dim ReportFormatString As String = GridRow.GetDataKeyValue("ReportFormat").ToString()
        ReportFormatddList.Items.FindByValue(ReportFormatString).Selected = True
 
 
 
        'this covers the report name field priming
        editor = CType(editMan.GetColumnEditor("ddReportName"), GridDropDownListColumnEditor)
        Dim ReportNameddList As DropDownList = editor.DropDownListControl
        ReportNameddList.DataSource = (From r In DbContext.SubscriptionReportNames Select r.ReportName).ToList()
        ReportNameddList.DataBind()  '<-- this is the error line, but only when second row is being edited.

 
        'select the correct record
        Dim ReportNameString As String = GridRow.GetDataKeyValue("ReportName").ToString()
        ReportNameddList.Items.FindByValue(ReportNameString).Selected = True
 
 
 
    End If
End Sub

.aspx code
  <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="False"
            AllowPaging="True" AllowSorting="True" CellSpacing="0"
        GridLines="None" ShowGroupPanel="True" Skin="Web20">
            <MasterTableView DataKeyNames="ReportFormat,ReportName,FranchiseSubscriptionEmailID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" />
 
                    <telerik:GridBoundColumn DataField="FranchiseSubscriptionEmailID"
                        HeaderText="Record ID" ReadOnly="true"
                        ForceExtractValue="Always" ConvertEmptyStringToNull="true"
                        Visible="False" />
 
                    <telerik:GridBoundColumn DataField="FranchiseeID" HeaderText="Franchisee ID"
                        Visible="False" />
 
                <telerik:GridDropDownColumn DataSourceID="ReportNameddlist" ListTextField="ReportName"
                    ListValueField="ReportName" UniqueName="ddReportName" SortExpression="ReportName"
                    HeaderText="Report Name" DropDownControlType="DropDownList" ListDataMember="ReportName"
                        DataField="ReportName">
                </telerik:GridDropDownColumn>
 
                    <telerik:GridBoundColumn DataField="EmailAddress" HeaderText="Email Address" />
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Franchisee Name" />
 
                <telerik:GridDropDownColumn DataSourceID="ReportFormatddlist" ListTextField="ReportFormat"
                    ListValueField="ReportFormat" UniqueName="ddReportFormat" SortExpression="ReportFormat"
                    HeaderText="Report Format" DropDownControlType="DropDownList"
                        DataField="ReportFormat" ListDataMember="ReportFormat">
                </telerik:GridDropDownColumn>
 
                    <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                       ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
 
                </Columns>
                <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" />
                </EditFormSettings>
            </MasterTableView>
            <PagerStyle Mode="NextPrevAndNumeric" />
            <ClientSettings AllowDragToGroup="True">
                <ClientEvents OnRowDblClick="rowDblClick" />
            </ClientSettings>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
        </telerik:RadGrid>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
justin
Top achievements
Rank 1
Share this question
or