473,587 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# App - Add DataGridView Column from DataRelation

AHayes
10 New Member
I'm having an issue that I can't seem to find a solution to online...so I'm hopeful that someone here has the solution for me.


_The Problem
I'm using a DataGridView control to display information from a table. However, the table I'm showing also displays an ID that is used to link to another table. For instance, "BookID" in Table A ("TheLibrary ") is used to link to Table B ("TheBooks") which has details about a given book with that ID.

What I need to do is show (to keep with my above example) the "BookName" from a related table instead of the "BookID" that's stored in the table the DataGridView is showing.


_The Code
Expand|Select|Wrap|Line Numbers
  1. dstData.ReadXmlSchema(strSchemaFilePath);
  2. dstData.ReadXml(strXMLFilePath);
  3.  
  4. DataRelation dtrBookToLibrary = new DataRelation("BookToLibrary", dstData.Tables["TheBook"].Columns["BookID"], dstData.Tables["TheLibrary"].Columns["BookID"]);
  5. dstData.Relations.Add(dtrBookToLibrary);
  6.  
  7. dvwLibrary.Table = dstData.Tables["TheLibrary"];
  8. dvwBooks.Table = dstData.Tables["TheBooks"];
  9.  
  10. grdLibraryView.DataSource = dvwLibrary;
  11.  
Dec 12 '07 #1
0 1340

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6403
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I gave it a try using the example given in
1
4696
by: mark carew | last post by:
Hi, Problem - An extra column to the left (even with row headers disabled) ---------------------------------------------------------- Apologies if this posting is already in the newsgroup; but have changed to 40tude and can't see it in the newly dowloaded messages. It was originally html (tut tut) so maybe it didn't register. I have tried...
1
12609
by: Jan Lorenz | last post by:
Hello, my problem is to show a datarelation between two tables (parent/child) in a datagridview. It doesn't works. There is always shown only 1 table in the grid (in relation of DataMember-settings). My code is: DataSet ds = new DataSet();
1
2304
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a dataAdapter/Dataset using a dataview which is the data source for a datagridview control. When I scroll horizontally in the datagridview control and reach...
2
11460
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows in datagridview2 that corresponded to a selected row in datagridview1. Great article/example.
7
12584
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's the background for my question... Before I switched my application over to the Fx 2.0, I used a DataGrid to display my data. I would store...
1
2498
by: weird0 | last post by:
How can i update the data in my database directly through datagridview....? Can anyone tell me the appropriate links and what is the exact event in datagridview that handles it and some explanation abut how to handle it. what does ds.Tables...ds.Tables return by the way? What does it mean? DatagridView.DataSource=ds.Tables; // one of the...
6
2842
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab through the new row being added. It does not 'Add' that row, nor setup the 'next blank add row' so I can continue to tab
0
5640
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be blank unless they are filled by the user. 2) As soon as the user enters a cell, the dtp control should appear as the editing control of that cell. If...
0
7920
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
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...
0
5394
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...
0
3844
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...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
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...

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.