On Jul 12, 3:35 pm, "Fred Mertz" <A...@B.COMwrote:
One option is to use the generic BindingList<Tclass.
http://msdn2.microsoft.com/en-us/lib...Mtps_DropDownF...
"cowznofsky" <jhco...@yahoo.comwrote in message
news:11*********************@57g2000hsv.googlegrou ps.com...
I'm getting data in a generic list class, which I'm not going to
change. I would like to
use it as a datasource for a datagrid or a gridview, but it doesn't
implement IEnumerable.
I'm wondering if there's a simple technique that would allow me to get
the data into the datagrid.- Hide quoted text -
- Show quoted text -
Well, this looked to be just what I needed, but I haven't been able to
get it to work.
In the code below I have my original generic list, myColumns, and my
BindingList, bColumns. I populate bColumns, and I confirm that I can
get a value from the 'DB_Column_Name' property.
Then I try to populate a dropdownlist box. Perhaps I may be using the
wrong syntax here.
But I also try to populate a datagrid, and get an error saying that
'DB_Column_Name' is not found. If I try change the grid to
AutoGenerateColumns="True", it still does not work.
List<MasterColumnRecordmyColumns = wcc.Columns;
BindingList<MasterColumnRecordbColumns = new
BindingList<MasterColumnRecord>();
foreach (MasterColumnRecord mcr in myColumns)
{
bColumns.Add(mcr);
}
string test = bColumns[0].DB_Column_Name;
SortList.DataSource = bColumns;
SortList.DataMember = "DB_Column_Name";
SortList.DataBind();
DataGrid1.DataSource = bColumns;
DataGrid1.DataBind();