473,626 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

use data from second sqldatasource in gridview itemtemplate?

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.

Mar 20 '06 #1
4 2036
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.

Mar 21 '06 #2
Well, generally I'm trying to solve the issue of displaying relational data
in a GridView. Given table "commuters" and table "OfficePark s", 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
EditItemTemplat e 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.

Mar 21 '06 #3
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 EditItemTempalt e, 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 "OfficePark s", 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
EditItemTemplat e 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.

Mar 21 '06 #4

Thanks Phillip, you're a prince! I implemented the join solution while you
were typing this up, I still have to code the EditItemTemplat e 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 EditItemTempalt e, 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 "OfficePark s", 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
EditItemTemplat e 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.
>

Mar 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6541
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
9
5326
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be (filtered) dependent upon the selection in DDL1. I think this inevitably needs some code, but I'd be happy to be told otherwise! I have some code to handle OnSelectedIndexChanged for DDL1 that sets the FilterExpression associated with the...
1
3493
by: SomebodyElse | last post by:
Hi. Apologies if this has been asked here before - I've searched & searched but can't find anything. It's probably my serach parameters, but I'm having trouble even describing it to a search engine! I'm sure this is a very simple problem, with straighforward solution. It certainly is in classic asp/ado, but I'm finally learning this .NET business. I like it, but can't get my head around some concepts. Anyway....
1
1794
by: Avanti | last post by:
Hello, I have a gridview wherein I've added functionality for Edit. Now, when I click on the Edit button, and modify a field, and click on the Update button, the new values disappear and the old values are retained. Here is my source code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
6
2388
by: Dabbler | last post by:
I have a GridView with a couple of TemplateFields. When I click the update link the Gridview returns to display mode with no errors but the data from bound text fields or dropdown list isn't updated in the table. I'm stumped and any help would be appreciated. Thanks much. My GridView: <asp:GridView ID="VanListGridView" runat="server"
3
4522
by: simonZ | last post by:
In gridView I have dropdown list : <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
6
8895
by: Guabble | last post by:
Hi Can anyone help me? I want to be able to show my sqldatareader contents in a gridview whereby the child data is concatenated up in a single row. Is this possible? For example Author Name Book Titles Author1 Book1, Book2, Book3
2
6320
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I want to create a mailto link from data coming from an SQLDataSource. How do I have to change the following code to get it working? The mailto works, outlook starts with a new message, but the email address has not been filled in because I don’t know how to pass the email variable into the mailto command. <asp:HyperLink runat="server"> <A href="mailto:">
0
4051
by: troydixon | last post by:
Hello, I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the following: 1) gets query string from url and filters records (works great) via a Details View 2) shows notes that have been added to the record shown in the details view using a grid view, and it filters the data by looking at the ID that is selected in...
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.