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.One option is to use the generic BindingList<T> class.
[url]http://msdn2.microsoft.com/en-us/library/ms132679.aspx#Mtps_DropDownFilterText[/ur
l]
"cowznofsky" <jhcorey@.yahoo.com> wrote in message
news:1184265867.633987.87780@.57g2000hsv.googlegroups.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.
>
On Jul 12, 3:35 pm, "Fred Mertz" <A...@.B.COM> wrote:
> One option is to use the generic BindingList<T> class.
> http://msdn2.microsoft.com/en-us/li...ps_DropDownF...
> "cowznofsky" <jhco...@.yahoo.com> wrote in message
> news:1184265867.633987.87780@.57g2000hsv.googlegroups.com...
>
>
>
> - 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<MasterColumnRecord> myColumns = wcc.Columns;
BindingList<MasterColumnRecord> bColumns = 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();
On Jul 12, 4:10 pm, cowznofsky <jhco...@.yahoo.com> wrote:
> On Jul 12, 3:35 pm, "Fred Mertz" <A...@.B.COM> wrote:
>
>
>
>
>
>
>
>
> 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<MasterColumnRecord> myColumns = wcc.Columns;
> BindingList<MasterColumnRecord> bColumns = 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();
Ok, I think I see part of my problem. "DB_Column_Name" was a public
varable in the class. When I make it a property, the datagrid bind
works.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment