ObjectDataSource, GridView and ItemTemplate

Discussion in 'ASP .Net Web Controls' started by Mogens Nielsen - Elbek & Vejrup A/S, Mar 23, 2006.

  1. 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
     
    Mogens Nielsen - Elbek & Vejrup A/S, Mar 23, 2006
    #1
    1. Advertisements

  2. 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.asp
    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
     
    Phillip Williams, Mar 23, 2006
    #2
    1. Advertisements

  3. 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
     
    Mogens Nielsen - Elbek & Vejrup A/S, Mar 23, 2006
    #3
  4. 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
     
    Phillip Williams, Mar 23, 2006
    #4
  5. 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

    "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
     
    Mogens Nielsen - Elbek & Vejrup A/S, Mar 24, 2006
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    5,623
    Joe Fallon
    Sep 24, 2004
  2. ABC
    Replies:
    1
    Views:
    1,151
    Patirck Ige
    Oct 7, 2005
  3. =?Utf-8?B?RGFiYmxlcg==?=

    use data from second sqldatasource in gridview itemtemplate?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,278
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 21, 2006
  4. =?Utf-8?B?T3Bh?=
    Replies:
    3
    Views:
    2,391
    =?Utf-8?B?T3Bh?=
    Nov 1, 2006
  5. Paul
    Replies:
    2
    Views:
    9,607
    PhilTheGap
    May 29, 2008
  6. RenatoGuarilha
    Replies:
    1
    Views:
    208
    RenatoGuarilha
    Jan 19, 2006
  7. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    428
    Steven Cheng[MSFT]
    Mar 23, 2006
  8. theWizard1

    Gridview Headers for ItemTemplate and EditTemplate

    theWizard1, Sep 15, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    975
    theWizard1
    Sep 15, 2006
Loading...