473,507 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding DataGrid

Hello group,
I my apps I have two dataGrids - dgParent, dgChild to show rows from two
tables. Tables are relations one to more in dataBase.
I use sqlDataAdater (sdaParent, sdaChild) to fill myDS.
DataSource in dgParent I have set myDS.Tables["Parent"] (for dgChild
myDS.Tables["Child"]);
My questions:
How show in dgChild only rows where show only child for parent selected
in dgParent?
Which event us (double click, leave etc.)?

Maybe someone have any sample with resolving this problem.

Paweł
Nov 16 '05 #1
5 2664
Pawel,

Is this enough

DataGrid2.SetDataBinding(Ds, "Countries.Regulars");

"Countries.Regulars" is the child in a dataset relation where the first table is Countries and the second Regulars.

http://msdn.microsoft.com/library/de...tionstopic.asp

Mam nadzieje ze to pomorze?

Cor

Nov 16 '05 #2
Pawel,

Is this enough

DataGrid2.SetDataBinding(Ds, "Countries.Regulars");

"Countries.Regulars" is the child in a dataset relation where the first table is Countries and the second Regulars.

http://msdn.microsoft.com/library/de...tionstopic.asp

Mam nadzieje ze to pomorze?

Cor

Nov 16 '05 #3
Cor

Dzieki,
ale jakos nie mam podejscia tego. Fajnie jak bys mial chwile i na to
spojrzal.

Mam dataSet (specyfikowany na podstawie pliku xsd).
W ds dwie tabele Osoba (idOsoba(PK), Imie, Nazwisko ... ) i AdresEmail
(idEmail, idOsoba(FK), Adres). Polaczone sa one za pomoca relacji
OsobaAdresEmail.

Dzieki Twojej radzie do pierwszego dataGrid'u jako dgOsoba.DataSource =
ds.Osoba.DefaultView;
Nastepnie Binduje dane do textBox'ów tbImie.DataBindings.Add(new
Binding("Text", ds.Osoba.DefaultView, "Imie"));

Po dodaniu kolejnego dataGrida - dgEmail.SetDataBinding(ds,
"AdresEmail.idOsoba");
w trakcie dzialania otrzymuje blad "Specified cast is not valid."
jezeli ustawie dgEmail.SetDataBinding(ds, "OsobaAdresEmail.idOsoba"); lub
dgEmail.SetDataBinding(ds, "OsobaAdresEmail");
to jest nastepujacy blad "Cannot create a child list for field
OsobaAdresEmail"
Sprawdzilem typy pól w bazie i dataSet i one sie zgadzaja, o jakie
rzutowanie tu chodzi.

Wielkie dzieki

Pozdrawiam Pawel
Uzytkownik "Cor Ligthert" <no************@planet.nl> napisal w wiadomosci
news:%2****************@TK2MSFTNGP12.phx.gbl...
Pawel,

Is this enough

DataGrid2.SetDataBinding(Ds, "Countries.Regulars");

"Countries.Regulars" is the child in a dataset relation where the first
table is Countries and the second Regulars.

http://msdn.microsoft.com/library/de...tionstopic.asp

Mam nadzieje ze to pomorze?

Cor
Nov 16 '05 #4
Cor

Dzieki,
ale jakos nie mam podejscia tego. Fajnie jak bys mial chwile i na to
spojrzal.

Mam dataSet (specyfikowany na podstawie pliku xsd).
W ds dwie tabele Osoba (idOsoba(PK), Imie, Nazwisko ... ) i AdresEmail
(idEmail, idOsoba(FK), Adres). Polaczone sa one za pomoca relacji
OsobaAdresEmail.

Dzieki Twojej radzie do pierwszego dataGrid'u jako dgOsoba.DataSource =
ds.Osoba.DefaultView;
Nastepnie Binduje dane do textBox'ów tbImie.DataBindings.Add(new
Binding("Text", ds.Osoba.DefaultView, "Imie"));

Po dodaniu kolejnego dataGrida - dgEmail.SetDataBinding(ds,
"AdresEmail.idOsoba");
w trakcie dzialania otrzymuje blad "Specified cast is not valid."
jezeli ustawie dgEmail.SetDataBinding(ds, "OsobaAdresEmail.idOsoba"); lub
dgEmail.SetDataBinding(ds, "OsobaAdresEmail");
to jest nastepujacy blad "Cannot create a child list for field
OsobaAdresEmail"
Sprawdzilem typy pól w bazie i dataSet i one sie zgadzaja, o jakie
rzutowanie tu chodzi.

Wielkie dzieki

Pozdrawiam Pawel
Uzytkownik "Cor Ligthert" <no************@planet.nl> napisal w wiadomosci
news:%2****************@TK2MSFTNGP12.phx.gbl...
Pawel,

Is this enough

DataGrid2.SetDataBinding(Ds, "Countries.Regulars");

"Countries.Regulars" is the child in a dataset relation where the first
table is Countries and the second Regulars.

http://msdn.microsoft.com/library/de...tionstopic.asp

Mam nadzieje ze to pomorze?

Cor
Nov 16 '05 #5
Pawel,

I made a sample for you, maybe you can try it. It includes the creation of a
kind of strongly typed dataset.

\\\ needs two datagrids
private void Form1_Load(object sender,
System.EventArgs e)
{
dst ds = new dst();
dataGrid1.DataSource = ds.Polska;
dataGrid2.SetDataBinding (ds, "Polska.drlHolland");
}
}
public class dst : DataSet
{
public dst()
{
this.Tables.Add(dta(new DataTable("Polska")));
this.Tables.Add(dta(new DataTable("Holland")));
DataRelation drlHolland = new DataRelation("drlHolland",
this.Tables["Polska"].Columns["Pawel"],
this.Tables["Holland"].Columns["Pawel"]);
this.Relations.Add(drlHolland);
}
private DataTable dta (DataTable dt)
{
dt.Columns.Add("Pawel");
int total = 10;
if (dt.TableName=="Holland") total = 100;
for (int i=0;i<total;i++)
{
dt.Rows.Add(dt.NewRow());
if (dt.TableName=="Holland")
dt.Rows[i][0] = i/10;
else
dt.Rows[i][0]=i;
}
if (dt.TableName=="Holland")
{
dt.Columns.Add("Cor");
for (int i=0;i<total;i++)
{
dt.Rows[i][1] = i+100;
}
}
return dt;
}
public DataTable Polska {get{return this.Tables[0];}}
public DataTable Holland {get{return this.Tables[1];}}
}
}
///
I hope this helps a little bit?

Cor

Nov 16 '05 #6

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

Similar topics

0
2319
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
1
3467
by: Mike Dole | last post by:
Why is it that when I want to use an attribute like for instance: .WriteAttributeString("WaiterId", "14") and later on (in another application) want to bind the xml to a datagrid with readxml I'm...
0
4780
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
3
1566
by: Jim Bancroft | last post by:
Hi everyone, I'm binding an ArrayList to a DataGrid for the first time (I'm used to binding DataSets and DataTables) and I was wondering if I could somehow "name" the ArrayList, so that I can...
8
3914
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
5
2285
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
2
1746
by: yuanh23 | last post by:
Hi, I have 3 talbes "customers","orders","details". i wanna to use 3 datagrids to show those tables. and when the selected row in parent talbe changes, the selected row in child table changes...
6
5721
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
3
1665
by: no | last post by:
Hi all, I have a dataset that contain 2 tables and a relationship between them (master detail). I bind this dataset to a form that include some textboxes that bind to the parent record, and a...
1
2421
by: Stephen Barrett | last post by:
I have an application that was originally built with ASP.Net 1.1. We finally got permission to migrate to 2.0. Due to time constraints we migrated the web projects to 2.0 web application...
0
7223
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,...
1
7034
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
7488
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...
0
5623
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,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
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...
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.