473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

3
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 DataPropertyName 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 1560
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 DataPropertyName 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,pt.CustomerName,pt.StatusId,rt.Statu sDesc from parenttable pt,relatedtable rt where rt.CustomerId=pt.CustomerId";
OleDbCommand cmd=new OleDbCommand(str,conn);
OleDbDataAdapter ada=new OleDbDataAdapter(cmd);
DataSet ds=new DataSet();
ada.Fill(ds);

Datagrid.DataSource=ds;
DataGrid.DataBind();

and must set AutoGenerateClomns to false from datagrid property

I think this code will must help
Feb 22 '08 #2
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 dataGridViewComboBoxColumn you get some other options in the Data section of the edit columns dialog.

There is DataPropertyName, DataSource, DisplayMember, and ValueMember. Set the DataPropertyName 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
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...
2
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...
2
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,...
1
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...
2
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...
1
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...
5
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...
9
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...
6
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)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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...

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.