473,657 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Grid - Displaying a related column instead of parent id - URGENT HELP PLEASE

3 New Member
I'm in desperate need of knowing how I can bind my data grid so that I have the following

Customer ID - parent table
Customer Name - parent table
Status ID - parent table
Status Description - related table status

I want to pull in the status description from the relation I have set up on the dataset between the customer table and the status table based on the status ID!

Does anyone know how to do this?

I tried going into edit columns on the grid and changing the DataPropertyNam e to the Foreign Key link and the Status Description column, but the data does not appear!

I am filling the customer and status tables in the load event of the form.

Any help would be greatly appreciated!
Feb 21 '08 #1
2 1569
agarwalsunitadhn
82 New Member
I'm in desperate need of knowing how I can bind my data grid so that I have the following

Customer ID - parent table
Customer Name - parent table
Status ID - parent table
Status Description - related table status

I want to pull in the status description from the relation I have set up on the dataset between the customer table and the status table based on the status ID!

Does anyone know how to do this?

I tried going into edit columns on the grid and changing the DataPropertyNam e to the Foreign Key link and the Status Description column, but the data does not appear!

I am filling the customer and status tables in the load event of the form.

Any help would be greatly appreciated!

why dont you try to manually bind the datagrid with coding
like this

OleDbConnection conn=new OleDbConnection (conectionstr);
string str="select pt.CustomerId,p t.CustomerName, pt.StatusId,rt. StatusDesc from parenttable pt,relatedtable rt where rt.CustomerId=p t.CustomerId";
OleDbCommand cmd=new OleDbCommand(st r,conn);
OleDbDataAdapte r ada=new OleDbDataAdapte r(cmd);
DataSet ds=new DataSet();
ada.Fill(ds);

Datagrid.DataSo urce=ds;
DataGrid.DataBi nd();

and must set AutoGenerateClo mns to false from datagrid property

I think this code will must help
Feb 22 '08 #2
shlabadoo
4 New Member
I'm not sure if this works for DataGrids, but for a DataGridView you can set a column to be a ComboBox instead of a textbox. Then you can set both the display property and the value property to the other table.

When you change it to a dataGridViewCom boBoxColumn you get some other options in the Data section of the edit columns dialog.

There is DataPropertyNam e, DataSource, DisplayMember, and ValueMember. Set the DataPropertyNam e to the key that you are trying to not show, the DataSource to the binding source of the secondary table, DisplayMember to the name of the column you want to actually display and ValueMember to the primarykey of that table.

Then you can change the DisplayStyle to Nothing to get rid of the dropdown arrow.

Hopefully that pertains to your situation.

-dan
Feb 22 '08 #3

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

Similar topics

3
1640
by: Rajani | last post by:
Hello, I need to enter many entries at a time related to my production. Like operatorID,operationNO,qty,nohours bla bla I already designed page. But its used to enter one record at a time. I want to allow user to enter all operators details for a specific date at a time. I tried using ADO Connection and ADO recordset. When set the properties, its displaying error. Its not connecting to database. How can i use this? or is there any tool...
2
2157
by: Les | last post by:
Hi can anyone help me, I have just graduated and have started working for a building developer which deals with a large quantity of drawings. As you can imagine these all need documenting and revision of drawings kept a track of. I have recently taking over the administration of the drawings and their current system is not capable of easily managing the data so I have taken it upon myself to try and organise the data in a database....
2
2503
by: Susan Bricker | last post by:
Greetings! Still the same application (as previous posts). I worked on the app while at work (don't tell my boss ... cause this is just for fun and not work related) and the form was working, but now when I try to repeat the code at home (for real) it won't work. I suspect that I haven't replicated the logic and forms at home from what I remember that I did while at work. My subform is based on a table called "tblTrialClass" and it...
1
1487
by: Ananth | last post by:
Hi, I have a question regarding data grids My application requires me to use a grid for displaying data, however I would not be using a database for procuring the data, instead I would be exposing interfaces for other methods to pass me the data that needs to be displayed. In such a case is the data grid the best control to use in .NET? Also if I am using a data grid, how can I obtain the value in the current cell of the data grid?(where...
2
2496
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this person is taken are shown in a DataGrid (course name, price, etc.). This is working well so far, I...
1
1119
by: kamkoum | last post by:
Hello, I am using readxml to retrieve data from an xml file to a dataset. m xml file has hierarchical data (2 levels) so the dataset will contain tables. My question : I need to display this data like this :
5
6436
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
9
4012
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
6
2938
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
8385
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
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
7316
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 project—planning, coding, testing, and deployment—without 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
4150
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...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1601
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.