•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 401,949 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,295 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3844 | Replies: 6
![]() |
I'm sure this is easy, but I'm seeming to have a brainfart or something and can't find any ways to do this....
I have a gridview, which is displaying data from an objectdatasource/tableadapter. One of the columns in the gridview is a UserID. Instead of displaying the UserID, I want to display the corresponding Username from another objectdatasource based on that UserID. I swear I need to do something in the itemtemplate, but I'm not seeing it. Can someone point me in the right direction?
Thanks!
I have a gridview, which is displaying data from an objectdatasource/tableadapter. One of the columns in the gridview is a UserID. Instead of displaying the UserID, I want to display the corresponding Username from another objectdatasource based on that UserID. I swear I need to do something in the itemtemplate, but I'm not seeing it. Can someone point me in the right direction?
Thanks!
•
•
Join Date: Jan 2007
Location: Japan
Posts: 70
Reputation:
Rep Power: 2
Solved Threads: 4
If you are using the GUI to make your object data source then you will need to write a custom sql script to join the 2 tables on the user id so the username field will be available in your grid view
sedgey: so little daylight, too much caffeine
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
•
•
Join Date: Jan 2007
Location: Japan
Posts: 70
Reputation:
Rep Power: 2
Solved Threads: 4
select * from table1 t1 join t2 on t1.userID = t2.userID
when you are making your data source just use the write your own sql query option, it isnt rocket science! be not afraid!
when you are making your data source just use the write your own sql query option, it isnt rocket science! be not afraid!
Last edited by sedgey : Feb 9th, 2007 at 5:51 pm.
sedgey: so little daylight, too much caffeine
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
Unless you're stuck with someone else's DAL, that is. 
You can write custom code to get the value, but it's a serious pain in the behind and isn't actually binding. You have to write custom code in the onItemDataBound event, I believe.
If you can write your own query, it's a LOT simpler.

You can write custom code to get the value, but it's a serious pain in the behind and isn't actually binding. You have to write custom code in the onItemDataBound event, I believe.
If you can write your own query, it's a LOT simpler.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
Thanks all...yes, I can write my own query, and that's what I ended up doing. I was just trying to abstract it out as much as possible, without having to make custom queries, stored procs, etc. for each different thing I wanted to display. I think I've done stuff before with the onItemDataBound event or something like it, so maybe I'll look into that again. Thanks again!
You don't have to display every column you select.
I use views with a bunch of columns as my datasource, and they work for several different grids.
I use views with a bunch of columns as my datasource, and they work for several different grids.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net .net framework 3.0 access ajax asp breach broadband code combo crime custom daniweb data data protection data transfer database developer development dom drive dropdownlist feed forensics government hard hardware hitachi internet linux microsoft module msdn net news office reader reuse security skin software sql storage terabyte theme vista weather web wikipedia xml xoap
- Gridview Paging Problem. (C#)
- datagrid-recordset (Visual Basic 4 / 5 / 6)
- Age sorting in Gridview urgent please >>>>>>>>>>> (ASP.NET)
- Help! Emergendy Case (ASP.NET)
- C# .NET Gridview (C#)
- Special formatting of a GridView... (ASP.NET)
- ComboBox bind data problem (VB.NET)
- GridView Edit and Delete buttons (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Current month name
- Next Thread: .NET ASPX worker process locks images referenced by PDF


Linear Mode