use data from second sqldatasource in gridview itemtemplate?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006.

  1. I need to convert a CompanyId in one table to Company Name from another
    table for an ItemTemplate. I thought I would just add another SqlDataSource
    but not sure how to eval with the CompanyId parameter for the where clause in
    the select.

    Any clues would be appreciated.
     
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006
    #1
    1. Advertising

  2. Would a SQL join statement be what you are looking for? Or are you looking to
    select first a row of the GridView and then execute a sub query based on the
    selected Company ID?
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Dabbler" wrote:

    > I need to convert a CompanyId in one table to Company Name from another
    > table for an ItemTemplate. I thought I would just add another SqlDataSource
    > but not sure how to eval with the CompanyId parameter for the where clause in
    > the select.
    >
    > Any clues would be appreciated.
    >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 21, 2006
    #2
    1. Advertising

  3. Well, generally I'm trying to solve the issue of displaying relational data
    in a GridView. Given table "commuters" and table "OfficeParks", where a
    customer row has a key OfficeParkId that links to OfficeParks. I would like
    to show the OfficePark name in the Gridview.

    I guess this could be solved with a join but not sure what the
    EditItemTemplate would look like for this. For the ItemTemplate I was
    thinking more along the lines of having a Label control Text value set to the
    OfficePark name pulled using the OfficeParkId from the commuters table using
    a second SqlDataSource.

    "Phillip Williams" wrote:

    > Would a SQL join statement be what you are looking for? Or are you looking to
    > select first a row of the GridView and then execute a sub query based on the
    > selected Company ID?
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Dabbler" wrote:
    >
    > > I need to convert a CompanyId in one table to Company Name from another
    > > table for an ItemTemplate. I thought I would just add another SqlDataSource
    > > but not sure how to eval with the CompanyId parameter for the where clause in
    > > the select.
    > >
    > > Any clues would be appreciated.
    > >
     
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 21, 2006
    #3
  4. For the Itemtemplate, I think that the SQL join statement would be adequate
    and you only need one datasource to do that (let’s say “datasource1â€). As
    for the EditItemTempalte, if you intend to allow changing the OfficeParkID
    then you can implement a dropdownlist during the edit template that relies on
    a separate datasource object (datasource2) that retrieves all available
    selections for that customer. Upon edit you would grap the new selectedValue
    of the dropdownlist (the new OfficeParkID) and update “datasource1†with the
    customer’s record.

    If you need the code to implement a GridView that contains elements from
    several datatables look at the source code of this demo from my website:

    http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Dabbler" wrote:

    > Well, generally I'm trying to solve the issue of displaying relational data
    > in a GridView. Given table "commuters" and table "OfficeParks", where a
    > customer row has a key OfficeParkId that links to OfficeParks. I would like
    > to show the OfficePark name in the Gridview.
    >
    > I guess this could be solved with a join but not sure what the
    > EditItemTemplate would look like for this. For the ItemTemplate I was
    > thinking more along the lines of having a Label control Text value set to the
    > OfficePark name pulled using the OfficeParkId from the commuters table using
    > a second SqlDataSource.
    >
    > "Phillip Williams" wrote:
    >
    > > Would a SQL join statement be what you are looking for? Or are you looking to
    > > select first a row of the GridView and then execute a sub query based on the
    > > selected Company ID?
    > > --
    > > HTH,
    > > Phillip Williams
    > > http://www.societopia.net
    > > http://www.webswapp.com
    > >
    > >
    > > "Dabbler" wrote:
    > >
    > > > I need to convert a CompanyId in one table to Company Name from another
    > > > table for an ItemTemplate. I thought I would just add another SqlDataSource
    > > > but not sure how to eval with the CompanyId parameter for the where clause in
    > > > the select.
    > > >
    > > > Any clues would be appreciated.
    > > >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 21, 2006
    #4
  5. Thanks Phillip, you're a prince! I implemented the join solution while you
    were typing this up, I still have to code the EditItemTemplate with dropdown,
    will have a look at your code for how to update the datasource1 after user
    selects a new dropdownlist entry and commits.


    "Phillip Williams" wrote:

    > For the Itemtemplate, I think that the SQL join statement would be adequate
    > and you only need one datasource to do that (let’s say “datasource1â€). As
    > for the EditItemTempalte, if you intend to allow changing the OfficeParkID
    > then you can implement a dropdownlist during the edit template that relies on
    > a separate datasource object (datasource2) that retrieves all available
    > selections for that customer. Upon edit you would grap the new selectedValue
    > of the dropdownlist (the new OfficeParkID) and update “datasource1†with the
    > customer’s record.
    >
    > If you need the code to implement a GridView that contains elements from
    > several datatables look at the source code of this demo from my website:
    >
    > http://www.webswapp.com/codesamples/aspnet20/dependentlists/gridview.aspx
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Dabbler" wrote:
    >
    > > Well, generally I'm trying to solve the issue of displaying relational data
    > > in a GridView. Given table "commuters" and table "OfficeParks", where a
    > > customer row has a key OfficeParkId that links to OfficeParks. I would like
    > > to show the OfficePark name in the Gridview.
    > >
    > > I guess this could be solved with a join but not sure what the
    > > EditItemTemplate would look like for this. For the ItemTemplate I was
    > > thinking more along the lines of having a Label control Text value set to the
    > > OfficePark name pulled using the OfficeParkId from the commuters table using
    > > a second SqlDataSource.
    > >
    > > "Phillip Williams" wrote:
    > >
    > > > Would a SQL join statement be what you are looking for? Or are you looking to
    > > > select first a row of the GridView and then execute a sub query based on the
    > > > selected Company ID?
    > > > --
    > > > HTH,
    > > > Phillip Williams
    > > > http://www.societopia.net
    > > > http://www.webswapp.com
    > > >
    > > >
    > > > "Dabbler" wrote:
    > > >
    > > > > I need to convert a CompanyId in one table to Company Name from another
    > > > > table for an ItemTemplate. I thought I would just add another SqlDataSource
    > > > > but not sure how to eval with the CompanyId parameter for the where clause in
    > > > > the select.
    > > > >
    > > > > Any clues would be appreciated.
    > > > >
     
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 21, 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. Bennett Haselton
    Replies:
    1
    Views:
    5,340
    Joe Fallon
    Sep 24, 2004
  2. misiek
    Replies:
    7
    Views:
    6,834
    misiek
    Feb 28, 2006
  3. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    2
    Views:
    3,498
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 12, 2006
  4. phil
    Replies:
    2
    Views:
    1,127
    Shahzad Godil
    Nov 14, 2006
  5. yelipolok
    Replies:
    4
    Views:
    263
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page