Home All Groups Group Topic Archive Search About

ObjectDataSource, GridView and ItemTemplate

Author
23 Mar 2006 2:16 PM
Mogens Nielsen - Elbek & Vejrup A/S
Hi all,
I'm currently experimenting with the all new GridView. I have made an
objectDataSource bound to one of my business entities.
In the presentation layer I now wish to use the GridView and make an
ItemTemplate. However I can't seem to find out how to access the properties
of my object in the template. Eval-function doesn't seem to work with
object-binding.
Has anyone made an itemtemplate for the gridview using object binding ??

Thanks in advance...
Mogens Nielsen
Elbek & Vejrup A/S

Author
23 Mar 2006 2:38 PM
Phillip Williams
http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx
http://www.webswapp.com/codesamples/aspnet20/itemplate/gridview.aspx
http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspx http://www.webswapp.com/codesamples/aspnet20/gridview_multiplerows_selection/default.aspx
Show quote Hide quote
"Mogens Nielsen - Elbek & Vejrup A/S" wrote:

> Hi all,
> I'm currently experimenting with the all new GridView. I have made an
> objectDataSource bound to one of my business entities.
> In the presentation layer I now wish to use the GridView and make an
> ItemTemplate. However I can't seem to find out how to access the properties
> of my object in the template. Eval-function doesn't seem to work with
> object-binding.
> Has anyone made an itemtemplate for the gridview using object binding ??
>
> Thanks in advance...
> Mogens Nielsen
> Elbek & Vejrup A/S
Author
23 Mar 2006 8:49 PM
Mogens Nielsen - Elbek & Vejrup A/S
Nice samples, however my problem is that when binding a list of custom
objects to the gridview, I can't seem to bind to the properties of the bound
objects in the ItemTemplateField. I would like to use the Bind or Eval
methods, but those are restricted for data-objects only - as far as I see
it...

Hope anyone has further response...

TIA,
Mogens Nielsen
Elbek & Vejrup A/S

Show quoteHide quote
"Phillip Williams" wrote:

> http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx
> http://www.webswapp.com/codesamples/aspnet20/itemplate/gridview.aspx
> http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspx
> http://www.webswapp.com/codesamples/aspnet20/gridview_multiplerows_selection/default.aspx
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Mogens Nielsen - Elbek & Vejrup A/S" wrote:
>
> > Hi all,
> > I'm currently experimenting with the all new GridView. I have made an
> > objectDataSource bound to one of my business entities.
> > In the presentation layer I now wish to use the GridView and make an
> > ItemTemplate. However I can't seem to find out how to access the properties
> > of my object in the template. Eval-function doesn't seem to work with
> > object-binding.
> > Has anyone made an itemtemplate for the gridview using object binding ??
> >
> > Thanks in advance...
> > Mogens Nielsen
> > Elbek & Vejrup A/S
Author
23 Mar 2006 8:53 PM
Phillip Williams
If you look carefully at this sample
http://www.webswapp.com/codesamples/aspnet20/dropdownlist_gridview/default.aspx

You will see that it is using a class named clsOrder (whose source code is
listed).  The class has several public properties all of which are bound to
the GridView using either Bind or Eval.  

The use of the ObjectDataSource is what makes this possible. http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/57hkzhy5(VS.80).aspx

Show quoteHide quote
"Mogens Nielsen - Elbek & Vejrup A/S" wrote:

> Nice samples, however my problem is that when binding a list of custom
> objects to the gridview, I can't seem to bind to the properties of the bound
> objects in the ItemTemplateField. I would like to use the Bind or Eval
> methods, but those are restricted for data-objects only - as far as I see
> it...
>
> Hope anyone has further response...
>
> TIA,
> Mogens Nielsen
> Elbek & Vejrup A/S
>
> "Phillip Williams" wrote:
>
> > http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx
> > http://www.webswapp.com/codesamples/aspnet20/itemplate/gridview.aspx
> > http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspx
> > http://www.webswapp.com/codesamples/aspnet20/gridview_multiplerows_selection/default.aspx
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Mogens Nielsen - Elbek & Vejrup A/S" wrote:
> >
> > > Hi all,
> > > I'm currently experimenting with the all new GridView. I have made an
> > > objectDataSource bound to one of my business entities.
> > > In the presentation layer I now wish to use the GridView and make an
> > > ItemTemplate. However I can't seem to find out how to access the properties
> > > of my object in the template. Eval-function doesn't seem to work with
> > > object-binding.
> > > Has anyone made an itemtemplate for the gridview using object binding ??
> > >
> > > Thanks in advance...
> > > Mogens Nielsen
> > > Elbek & Vejrup A/S
Author
24 Mar 2006 8:59 AM
Mogens Nielsen - Elbek & Vejrup A/S
Hi Phillip,
thanks for pointing me in the right direction. Sorry that I didn't got it at
first...
I got it all working now. It seems that the Bind method must be used within
a server control's property, which I didn't realize before now.

Mogens Nielsen
Elbek & Vejrup A/S

Show quoteHide quote
"Phillip Williams" wrote:

> If you look carefully at this sample
> http://www.webswapp.com/codesamples/aspnet20/dropdownlist_gridview/default.aspx
>
> You will see that it is using a class named clsOrder (whose source code is
> listed).  The class has several public properties all of which are bound to
> the GridView using either Bind or Eval.  
>
> The use of the ObjectDataSource is what makes this possible.
> http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource(VS.80).aspx
>
> http://msdn2.microsoft.com/en-us/library/57hkzhy5(VS.80).aspx
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Mogens Nielsen - Elbek & Vejrup A/S" wrote:
>
> > Nice samples, however my problem is that when binding a list of custom
> > objects to the gridview, I can't seem to bind to the properties of the bound
> > objects in the ItemTemplateField. I would like to use the Bind or Eval
> > methods, but those are restricted for data-objects only - as far as I see
> > it...
> >
> > Hope anyone has further response...
> >
> > TIA,
> > Mogens Nielsen
> > Elbek & Vejrup A/S
> >
> > "Phillip Williams" wrote:
> >
> > > http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx
> > > http://www.webswapp.com/codesamples/aspnet20/itemplate/gridview.aspx
> > > http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspx
> > > http://www.webswapp.com/codesamples/aspnet20/gridview_multiplerows_selection/default.aspx
> > > --
> > > HTH,
> > > Phillip Williams
> > > http://www.societopia.net
> > > http://www.webswapp.com
> > >
> > >
> > > "Mogens Nielsen - Elbek & Vejrup A/S" wrote:
> > >
> > > > Hi all,
> > > > I'm currently experimenting with the all new GridView. I have made an
> > > > objectDataSource bound to one of my business entities.
> > > > In the presentation layer I now wish to use the GridView and make an
> > > > ItemTemplate. However I can't seem to find out how to access the properties
> > > > of my object in the template. Eval-function doesn't seem to work with
> > > > object-binding.
> > > > Has anyone made an itemtemplate for the gridview using object binding ??
> > > >
> > > > Thanks in advance...
> > > > Mogens Nielsen
> > > > Elbek & Vejrup A/S