Child to Parent Databindig

  • Thread starter Thread starter Adam Stirk
  • Start date Start date
A

Adam Stirk

I am trying to create a child to parent form with databinding is this
possible?

I have 2 tables one "Users" and another "UserStatus"

The "Users" table consists of :
int UserID
string Username
string Password
int UserStatusID

And the "UserStatus" table consists of :
int UserStatusID
string Description

The form I am trying to create consists of :
Label UserID
Textbox Username
Textbox Password
ComboBox Description

I am new to .NET and any help will appreciated.

Thanks

Adam Stirk
 
Hi Adam,

One way would be to use JOIN statament when loading records.
The other would be to add "calculated" columns to parent datatable and write
the children data into.
There are other ways though, depending on the situation.
 
Do you have an example?


Miha Markic said:
Hi Adam,

One way would be to use JOIN statament when loading records.
The other would be to add "calculated" columns to parent datatable and write
the children data into.
There are other ways though, depending on the situation.
 
Do you have an example?

Of which one?

The firt would be:
SELECT Users.*, UserStatus.Description FROM Users INNER JOIN UserStatus ON
Users.UserStatusId = UserStatus.UserStatusId

The second would be:

tblUsers.Columns.Add("Description", typeof(string))
foreach (DataRow row in tblUsers.Row)
{
DataRow childRow = tblUserStatus.Rows.Find(row["UserStatusId"]);
if (childRow != null)
row["Description"] = childRow["Description"];
}
 
So in a sense i have got to create my own databinding to get the results i
want.

If this is the case why did microsoft include databinding with winfoms???

Adam Stirk

Miha Markic said:
Do you have an example?

Of which one?

The firt would be:
SELECT Users.*, UserStatus.Description FROM Users INNER JOIN UserStatus ON
Users.UserStatusId = UserStatus.UserStatusId

The second would be:

tblUsers.Columns.Add("Description", typeof(string))
foreach (DataRow row in tblUsers.Row)
{
DataRow childRow = tblUserStatus.Rows.Find(row["UserStatusId"]);
if (childRow != null)
row["Description"] = childRow["Description"];
}
 
Back
Top