[Mono-bugs] [Bug 521951] New: Assigning DataTables to ComboBox DataSources causes cast execption

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jul 14 09:13:06 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=521951


           Summary: Assigning DataTables to ComboBox DataSources causes
                    cast execption
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i386
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: alisdair_little at yahoo.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1)
Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)

When assigning DataTables to the ComboBox.DataSource property an exception is
raised the second time.
Cannot cast from source type to destination type.

Reproducible: Always

Steps to Reproduce:
1. Create a windows forms based application.
2. Add "ComboBox1"
3. Add "ComboBox2"
4. Add the following code to form load
DataSet dataSet = new DataSet();
DataTable table1 = dataSet.Tables.Add("table1");
table1.Columns.Add(new DataColumn("value", typeof(String)));
table1.Rows.Add("a");
table1.Rows.Add("b");
comboBox1.DataSource = dataSet.Tables[0].DefaultView;
comboBox1.DisplayMember = "value";

DataTable table2 = dataSet.Tables.Add("table2");
table2.Columns.Add(new DataColumn("value", typeof(String)));
table2.Rows.Add("c");
table2.Rows.Add("d");
comboBox2.DataSource = dataSet.Tables[1].DefaultView;
comboBox2.DisplayMember = "value";

Actual Results:  
The application crashes on start up.

Expected Results:  
The application should start and populate the ComboBox controls.

A work around is to change the code to the following;

DataSet dataSet = new DataSet();
DataTable table1 = dataSet.Tables.Add("table1");
table1.Columns.Add(new DataColumn("value", typeof(String)));
table1.Rows.Add("a");
table1.Rows.Add("b");
DataTable table2 = dataSet.Tables.Add("table2");
table2.Columns.Add(new DataColumn("value", typeof(String)));
table2.Rows.Add("c");
table2.Rows.Add("d");
Console.WriteLine("Created Tables");

comboBox1.DataSource = dataSet.Tables[0].DefaultView;
comboBox1.DisplayMember = "value";
comboBox2.DataSource = dataSet.Tables[1].DefaultView;
comboBox2.DisplayMember = "value";

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list