I have a function that returns a DataTable
DataTable dt = GetAllObject(ogj_id);
Now I want to fill one MultiCheckCombo, below is the link where I got this MultiCheckCombo
The example of how to fill this MultiCheckCombo from link above is only with dataReader
OdbcConnection con = "get YOUR connection string";
con.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = con;
cmd.CommandText = "select text,id from ...........";
OdbcDataReader dr = cmd.ExecuteReader();
MultiCheckCombo1.ClearAll();
dr.Read();
MultiCheckCombo1.AddItems(dr, "text", "id");
Query – Now my question sounds like this: How to convert DataTable in dataReader to fill this MultiCheckCombo?
Find a different control. That one is hard-coded to using an
OdbcDataReader. You don’t use aDataReaderto read data from aDataTable– you iterate through theDataRows.As a workaround, you could overload AddItems to accept a DataTable: