473,378 Members | 1,407 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,378 software developers and data experts.

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 2660
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
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
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
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
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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

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.