I'm converting an ASP.NET page to a Windows Form (in C#).
I have a 'filter definition' screen where I allow someone to filter a historical file based on a set of reason codes (that are stored in a config table). The user might select one reason code, or two, or twenty...so I used a CheckedListBox control.
In ASP.NET, it worked fine...here's what I did...
dim SqlCon as new SqlConnection("server=...")
dim sqlda as new sqldataadapter("select descr,rsncode
from rsncode",sqlcon)
dim ds as new dataset()
sqlda.fill(ds,"rsncode")
dim dt as datatable = ds.tables(0)
mychecklist.datasource = dt
mychecklist.DataTextField = "Descr"
mychecklist.DataValueField = "RsnCode"
mychecklist.DataBind()
My problem is that when I try to do the same type of thing in C# using WinForms, I get error messages when I try to set the DataSource of the CheckedListBox to the 'DT' data table object...I get an error message saying 'an object reference is required for the non-static property'.
Aside from the difference in syntax, I would have thought I could do the same general thing in C#. I'm sure I'm doing something wrong, but am not sure exactly what.
Thanks in advance,
Kevin