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

Possible Bug? RadDropDownList and DataView

4 Answers 163 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Jason Parrish
Top achievements
Rank 1
Jason Parrish asked on 23 Jun 2011, 03:59 PM
I am experiencing a strange behavior on the RadDropDownList when its datasource is a DataView.  I created an empty project to eliminate other possible factors.

On initial load, I set the datasource to a global dataview object, as well as the ValueMember and DisplayMember.  The dropdownlist is populated when clicking a single button.  As expected, the data is shown correctly.

If the dataview is refreshed multiple times (button clicked again), the data is shown correctly.  However, if the user drops down the listbox before refreshing the data, the text for the items in the dropdownlist changes to "System.Data.DataRowView".  

I have tried resetting the datasource, displaymember, valuemember, and performing a rebind after refreshing the data.  I still encounter the same issue.

Test code is below.  To see the strange behavior, add "RadDropDownList1.ShowDropDown()"  after refreshing the data.  Or simply display the dropdownlist before clicking the button. 

Possible bug????  This can't be by design.  :-)  This behavior does not occur with the MS dropdownlist control.  I have the latest version (2011.1.11.419).

Imports System.Data.SqlClient
 
Public Class Form1
    Private _dvNames_List As New DataView
 
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
 
        Dim sSQLConnection As String = "MYSQLCONNECTION"
        Dim oConn As New SqlConnection(sSQLConnection)
        Dim oCommand As New SqlCommand
 
        Dim oDT As New DataTable
        Dim oDA As SqlDataAdapter
 
        Try
            oConn.Open()
            With oCommand
                .Connection = oConn
                .CommandTimeout = 15
                .CommandType = CommandType.StoredProcedure
                .CommandText = "cp_MyStoredProc"
            End With
 
            oDA = New SqlDataAdapter(oCommand)
            oDA.Fill(oDT)
 
            oDT.TableName = "SQLDATATABLE"
            _dvNames_List.Table = oDT
 
        Catch ex As Exception
            Throw New Exception(ex.Message, ex)
        End Try
    End Sub
 
 
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        RadDropDownList1.ValueMember = "nameid"
        RadDropDownList1.DisplayMember = "name"
        RadDropDownList1.DataSource = _dvNames_List
    End Sub
End Class


4 Answers, 1 is accepted

Sort by
0
m.wujec
Top achievements
Rank 1
answered on 26 Jun 2011, 09:53 PM
The same problem in my code. Code below generates properly every item, but first item is displayed as "System.DataRow.DataRowView". In debug mode display value is proper, but dropdownlist in runtiem display it wrong.
I'm using latest release of winforms. (2011.1 11.419 (Apr 19, 2011))
public static void FillCB(RadDropDownList cb, object DataSource)
{
    cb.BeginUpdate();
    cb.DataSource = DataSource;
    cb.DisplayMember = "Nazwa";
    cb.ValueMember = "Id";
    cb.SortStyle = SortStyle.Ascending;
    cb.SelectedIndex = cb.Items.First.RowIndex;
    cb.EndUpdate();
}
0
Peter
Telerik team
answered on 28 Jun 2011, 11:28 AM
Hi all,

Thank you for the reporting this issue.

We have observed a similar behavior in the case where the user sets incorrect display member or where the data set is rebuild with different display member.

I cannot reproduce the issue with my test project - please modify my project so that it replicates the issue, or send me your own project which demonstrates your case. This will allow me to undersatand your exact scenario and provide you with further assistance.

Please note that you have to open a new support ticket in order to be able to attach your files.

Greetings,
Peter
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Jason Parrish
Top achievements
Rank 1
answered on 28 Jun 2011, 03:01 PM
Thank you for the sample code.  However, it does not follow the same code that I provided.  Try this code....I will also open a support ticket with the entire solution attached.

Public Class Form1
    Private dv As New DataView
 
    Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
        RefreshData()
        MsgBox("List is good...do not drop down list!")
    End Sub
 
    Private Sub RefreshData()
        Dim dt As New DataTable()
        dt.Columns.Add("Id", GetType(Integer))
        dt.Columns.Add("Nazwa", GetType(String))
        dt.Rows.Add(1, "Aaaa " & Now.Ticks)
        dt.Rows.Add(1, "Bbbb " & Now.Ticks)
        dt.Rows.Add(1, "Cccc " & Now.Ticks)
        dt.Rows.Add(1, "Dddd " & Now.Ticks)
        dt.TableName = "MYTABLE"
        dv.Table = dt
        dt.Dispose()
    End Sub
 
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        RadDropDownList1.BeginUpdate()
        RadDropDownList1.DataSource = dv
        RadDropDownList1.DisplayMember = "Nazwa"
        RadDropDownList1.ValueMember = "Id"
        RadDropDownList1.SortStyle = Telerik.WinControls.Enumerations.SortStyle.Ascending
        RadDropDownList1.SelectedIndex = RadDropDownList1.Items.First.RowIndex
        RadDropDownList1.EndUpdate()
    End Sub
 
    Private Sub RadButton2_Click(sender As Object, e As System.EventArgs) Handles RadButton2.Click
        RadDropDownList1.ShowDropDown()
        MsgBox("Dropdown shown!  Bug will now occur...refreshing data...")
        RefreshData()
    End Sub
 
    Private Sub RadButton3_Click(sender As Object, e As System.EventArgs) Handles RadButton3.Click
        MsgBox("List is good again...do not drop down list!")
        RefreshData()
    End Sub
End Class
0
Peter
Telerik team
answered on 29 Jun 2011, 02:25 PM
Hi Jason,

Thank you for the provided project.

If has pointed us directly to the issue. Currently, there is no workaround and we will provide fix in our next release scheduled for the middle of July.

I have updated your Telerik points for bringing this issue to us and for the cooperation.

Best wishes,
Peter
the Telerik team

Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Kelly
Top achievements
Rank 1
commented on 14 Jul 2022, 05:06 PM

I encountered this problem today, July 14, 2022.  This first post I saw on this problem was in 2011!  This problem still exists.

Here is the solution, that I didn't see posted anywhere in all that time.

    RemoveHandler ddlProcessingBinID.SelectedValueChanged, AddressOf ddlProcessingBinID_SelectedValueChanged
    Me.ddlProcessingBinID.DataSource = Nothing
    cdtCplBin = CplBinDAO.GetCutoffCplBinForMSPK(Microschedule.ManufacturingOrderMicroSchedulePK, "THREAD", Me.cdtConsumptionIpscoProduct.Rows(0)("cpl_process_status_pk"), Me.cdtConsumptionIpscoProduct.Rows(0)("ipsco_product_pk"))
    Me.ddlProcessingBinID.DisplayMember = "bin_id"
    Me.ddlProcessingBinID.ValueMember = "cpl_bin_pk"
    Me.ddlProcessingBinID.DataSource = cdtCplBin
    AddHandler ddlProcessingBinID.SelectedValueChanged, AddressOf ddlProcessingBinID_SelectedValueChanged

You have to reinitialize all databinding properties in the correct order for this to work properly.  I'm actually surprised this bug still exists.

Thanks.

Jason Parrish
Top achievements
Rank 1
commented on 14 Jul 2022, 08:35 PM

I'm not. :-D
Dess | Tech Support Engineer, Principal
Telerik team
commented on 18 Jul 2022, 06:19 AM

Hello,

I would like to note that when setting the DataSource property for RadDropDownList it is necessary to specify its DisplayMember and ValueMember properties. Thus, the respective values will be extracted from the assigned collection and the items in the drop down wouldn't be displayed with "System.DataRow.DataRowView". Additional information about how to setup properly RadDropDownList is demonstarted here: https://docs.telerik.com/devtools/winforms/controls/dropdown-listcontrol-and-checkeddropdownlist/dropdownlist/populating-with-data/data-binding 

Tags
DropDownList
Asked by
Jason Parrish
Top achievements
Rank 1
Answers by
m.wujec
Top achievements
Rank 1
Peter
Telerik team
Jason Parrish
Top achievements
Rank 1
Share this question
or