DataBinder.Eval and fields with a dot in the name

Discussion in 'ASP .Net' started by =?iso-8859-1?Q?S=F8ren_Lund?=, May 13, 2004.

  1. Hello,

    I am trying to bind a DataGrid with some data from a DataSet which
    contains fields in the form "group.fieldname". I am certain that my
    data source contains the field but I cannot get my head around which
    syntax to use when specifying which field to bind to the DataGrid.

    I have tried

    <%# DataBinder.Eval( Container.DataItem, "Group.FieldName" ) %>

    and

    <%# DataBinder.Eval( Container.DataItem, "[Group.FieldName]" %> which
    is just plain old wrong :)

    Can any one help me out here?

    --
    Med venlig hilsen,
    Søren Lund
    http://www.publicvoid.dk
     
    =?iso-8859-1?Q?S=F8ren_Lund?=, May 13, 2004
    #1
    1. Advertising

  2. hi Søren Lund,

    text='<%#DataBinder.Eval(Container.DataItem, "Desc")%>'

    you need to give the name of the field.

    HTH
    Regards
    Ashish M Bhonkiya
    "Søren Lund" <> wrote in message
    news:...
    > Hello,
    >
    > I am trying to bind a DataGrid with some data from a DataSet which
    > contains fields in the form "group.fieldname". I am certain that my
    > data source contains the field but I cannot get my head around which
    > syntax to use when specifying which field to bind to the DataGrid.
    >
    > I have tried
    >
    > <%# DataBinder.Eval( Container.DataItem, "Group.FieldName" ) %>
    >
    > and
    >
    > <%# DataBinder.Eval( Container.DataItem, "[Group.FieldName]" %> which
    > is just plain old wrong :)
    >
    > Can any one help me out here?
    >
    > --
    > Med venlig hilsen,
    > Søren Lund
    > http://www.publicvoid.dk
     
    Ashish M Bhonkiya, May 13, 2004
    #2
    1. Advertising

  3. is the datasource a custom collection or is Group.FieldName one of your
    columns in the db?

    --
    Swanand Mokashi
    Microsoft Certified Solution Developer (.NET)
    Microsoft Certified Application Developer (.NET)
    http://www.swanandmokashi.com/
    http://www.swanandmokashi.com/HomePage/WebServices/
    Home of the Stock Quotes, Quote of the day and Horoscope web services
    "Søren Lund" <> wrote in message
    news:...
    > Hello,
    >
    > I am trying to bind a DataGrid with some data from a DataSet which
    > contains fields in the form "group.fieldname". I am certain that my
    > data source contains the field but I cannot get my head around which
    > syntax to use when specifying which field to bind to the DataGrid.
    >
    > I have tried
    >
    > <%# DataBinder.Eval( Container.DataItem, "Group.FieldName" ) %>
    >
    > and
    >
    > <%# DataBinder.Eval( Container.DataItem, "[Group.FieldName]" %> which
    > is just plain old wrong :)
    >
    > Can any one help me out here?
    >
    > --
    > Med venlig hilsen,
    > Søren Lund
    > http://www.publicvoid.dk
     
    Swanand Mokashi, May 13, 2004
    #3
  4. Swanand Mokashi wrote:

    > is the datasource a custom collection or is Group.FieldName one of
    > your columns in the db?


    The field is from a standard dataset which has been populated through a
    custom oledb provider (a Commerce Server provider if that is any help
    to you).

    --
    Med venlig hilsen,
    Søren Lund
    http://www.publicvoid.dk
     
    =?iso-8859-1?Q?S=F8ren_Lund?=, May 14, 2004
    #4
  5. Ashish M Bhonkiya wrote:

    Yes I know, the problem is that the databinder returns an error if I
    specify that name with a dot in it. My fields are named
    "blabla.theotherthing" which throws an exception at runtime, like this:

    DataBinder.Eval: 'System.Data.DataRowView' does not contain a property
    with the name GeneralInfo.

    Notice ths dot at the end of the exception, the field is actually named
    GeneralInfo.logon_name. It seems to me that the databinder stops
    processing when it reaches the dot even though there's more of the name
    left? Kinda weird.

    Also I am able to bind the data to the DataGrid if I AutoGenerate the
    columns of the DataGrid but that's really not what I am looking for.

    >
    > text='<%#DataBinder.Eval(Container.DataItem, "Desc")%>'
    >
    > you need to give the name of the field.


    > > I am trying to bind a DataGrid with some data from a DataSet which
    > > contains fields in the form "group.fieldname". I am certain that my
    > > data source contains the field but I cannot get my head around which
    > > syntax to use when specifying which field to bind to the DataGrid.
    > >
    > > I have tried
    > >
    > > <%# DataBinder.Eval( Container.DataItem, "Group.FieldName" ) %>
    > >
    > > and
    > >
    > > <%# DataBinder.Eval( Container.DataItem, "[Group.FieldName]" %>
    > > which is just plain old wrong :)
    > >
    > > Can any one help me out here?



    --
    Med venlig hilsen,
    Søren Lund
    http://www.publicvoid.dk
     
    =?iso-8859-1?Q?S=F8ren_Lund?=, May 14, 2004
    #5
    1. Advertising

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. Lauchlan M
    Replies:
    1
    Views:
    7,334
    Lauchlan M
    Oct 15, 2003
  2. Phil Winstanley [Microsoft MVP]

    Re: DataBinder.Eval and fields with a dot in the name

    Phil Winstanley [Microsoft MVP], May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    525
    Phil Winstanley [Microsoft MVP]
    May 13, 2004
  3. Eric Newton
    Replies:
    3
    Views:
    9,591
    Brock Allen
    Apr 4, 2005
  4. DataBinder.Eval and Eval.

    , Jun 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    577
    Karl Seguin [MVP]
    Jun 16, 2006
  5. Replies:
    6
    Views:
    287
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
Loading...

Share This Page