Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > use data from second sqldatasource in gridview itemtemplate?

Reply
Thread Tools

use data from second sqldatasource in gridview itemtemplate?

 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-20-2006
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      03-21-2006
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.
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-21-2006
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.
> >

 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      03-21-2006
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/.../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.
> > >

 
Reply With Quote
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-21-2006

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/.../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.
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to use or not to use sqldatasource JohnE ASP .Net 3 01-31-2010 04:27 AM
strip all but second second line from bottom and then strip that!!!! yelipolok Perl Misc 4 01-27-2010 08:14 AM
Re-use data from sqldatasource control? Mike ASP .Net 1 12-12-2006 12:44 PM
gridview and sqldatasource - refresh the gridview phil ASP .Net 2 11-14-2006 06:09 AM
How to change data displayed in one GridView depending on selection made in the second one? (ASP.NET 2.0) misiek ASP .Net 7 02-28-2006 09:40 AM



Advertisments