How to get more data from a gridview's underlying datasource?

Discussion in 'ASP .Net' started by Curious Trigger, Jul 23, 2006.

  1. Hi there,

    I have got a gridview showing a display-name of a person and keeping its
    person-id as value accessible.

    Now I am wondering how I can get to his age, if this field isn't visible in
    the gridview but definied in the underlying datasource (a dataset)?

    Has anyone got a idea on this problem?

    Thank you for your quick answers!

    Sincerly yours,
    Curious SQL-Trigger
     
    Curious Trigger, Jul 23, 2006
    #1
    1. Advertising

  2. The grid items (row) have property DataItem. You need to typecast it to the
    type representing a row in your datasource.
    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "Curious Trigger" <> wrote in message
    news:...
    > Hi there,
    >
    > I have got a gridview showing a display-name of a person and keeping its
    > person-id as value accessible.
    >
    > Now I am wondering how I can get to his age, if this field isn't visible
    > in the gridview but definied in the underlying datasource (a dataset)?
    >
    > Has anyone got a idea on this problem?
    >
    > Thank you for your quick answers!
    >
    > Sincerly yours,
    > Curious SQL-Trigger
    >
     
    Eliyahu Goldin, Jul 23, 2006
    #2
    1. Advertising

  3. Eliyahu, thanks a lot for this tipp. I will give it a try and tell you the
    outcoming.

    Curious Trigger

    "Eliyahu Goldin" <> schrieb im Newsbeitrag
    news:...
    > The grid items (row) have property DataItem. You need to typecast it to
    > the type representing a row in your datasource.
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    > "Curious Trigger" <> wrote in message
    > news:...
    >> Hi there,
    >>
    >> I have got a gridview showing a display-name of a person and keeping its
    >> person-id as value accessible.
    >>
    >> Now I am wondering how I can get to his age, if this field isn't visible
    >> in the gridview but definied in the underlying datasource (a dataset)?
    >>
    >> Has anyone got a idea on this problem?
    >>
    >> Thank you for your quick answers!
    >>
    >> Sincerly yours,
    >> Curious SQL-Trigger
    >>

    >
    >
     
    Curious Trigger, Jul 23, 2006
    #3
  4. Curious Trigger

    Greg9Strat Guest

    There's a couple of ways you can add this. I assume you are using some
    version of Visual Studio 2005/Express... In the designer, the smart
    tag/menu has an "Edit Items" command that will open a new window and
    you can add the item there (add a BoundField). In the properties, put
    the column name from your query into the "DataTextField" property.
    This is the easiest of methods...

    If you are more comfortable with the code or are not using an IDE like
    VS 2005, then locate the control in your source and add the following
    to <asp:GridView> - <Columns>

    <asp:BoundField DataField="data_age" HeaderText="Age"
    SortExpression="data_age"/>

    Replace 'data_age' with whatever your query is returning.

    Curious Trigger wrote:
    > Hi there,
    >
    > I have got a gridview showing a display-name of a person and keeping its
    > person-id as value accessible.
    >
    > Now I am wondering how I can get to his age, if this field isn't visible in
    > the gridview but definied in the underlying datasource (a dataset)?
    >
    > Has anyone got a idea on this problem?
    >
    > Thank you for your quick answers!
    >
    > Sincerly yours,
    > Curious SQL-Trigger
     
    Greg9Strat, Jul 24, 2006
    #4
  5. Thanks for this info!

    What I am searching for is how I can get to a column of a gridview, if this
    column is defined in the underlying datasource but in the gridview it is
    invisible. It is strange that I am not able to access this invisible piece
    of information; at least not through the gridview. I have still to test the
    advice of Mr. Goldin: getting the actual datarow of the underlying
    datasource sounds very reasonable for me.

    Yours Curious Trigger

    "Greg9Strat" <> schrieb im Newsbeitrag
    news:...
    > There's a couple of ways you can add this. I assume you are using some
    > version of Visual Studio 2005/Express... In the designer, the smart
    > tag/menu has an "Edit Items" command that will open a new window and
    > you can add the item there (add a BoundField). In the properties, put
    > the column name from your query into the "DataTextField" property.
    > This is the easiest of methods...
    >
    > If you are more comfortable with the code or are not using an IDE like
    > VS 2005, then locate the control in your source and add the following
    > to <asp:GridView> - <Columns>
    >
    > <asp:BoundField DataField="data_age" HeaderText="Age"
    > SortExpression="data_age"/>
    >
    > Replace 'data_age' with whatever your query is returning.
    >
    > Curious Trigger wrote:
    >> Hi there,
    >>
    >> I have got a gridview showing a display-name of a person and keeping its
    >> person-id as value accessible.
    >>
    >> Now I am wondering how I can get to his age, if this field isn't visible
    >> in
    >> the gridview but definied in the underlying datasource (a dataset)?
    >>
    >> Has anyone got a idea on this problem?
    >>
    >> Thank you for your quick answers!
    >>
    >> Sincerly yours,
    >> Curious SQL-Trigger

    >
     
    Curious Trigger, Jul 24, 2006
    #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. Michael
    Replies:
    4
    Views:
    468
    Matt Hammond
    Jun 26, 2006
  2. djc
    Replies:
    2
    Views:
    183
  3. bernadou

    Read underlying data in GridView row?

    bernadou, Jan 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    591
    Phillip Williams
    Jan 22, 2006
  4. placek
    Replies:
    6
    Views:
    218
  5. jobs
    Replies:
    2
    Views:
    1,715
Loading...

Share This Page