dreamer610
MIS
Hi,
I'm just starting out with ASP.net and need some help. I am attempting to create a page with a datagrid that contains data from two different tables. This page is part of a message board system. I want to use a field called UserID in one of my tables, to pull the Name of the user who posted the message from another table in another database. I believe this should be able to be done using a DataRelation, but I just can't figure out exactly what do to. I've tried a few things, but none of them seem to work. Any help would be greatly appreciated. Below is the portion of the code I am using:
dim ds1 as dataset = new Dataset()
BoardCommand.fill(ds1, "tblViewMessage")
UsersCommand.fill(ds1, "tblMainUsers")
dim dr as datarelation = new Datarelation ("MessageUserInfo", ds1.tables("tblMainUsers").columns("ID"), ds1.tables("tblViewMessage").columns("UserID"))
DS1.Relations.Add(dr)
MessageTitleDataGrid.DataSource = ds1.Tables("tblViewMessage").DefaultView
MessageDataGrid.DataSource = ds1.Tables("tblViewMessage").DefaultView
UserDataGrid.DataSource = ds1.Tables("tblMainUsers").DefaultView
Databind()
I'm just starting out with ASP.net and need some help. I am attempting to create a page with a datagrid that contains data from two different tables. This page is part of a message board system. I want to use a field called UserID in one of my tables, to pull the Name of the user who posted the message from another table in another database. I believe this should be able to be done using a DataRelation, but I just can't figure out exactly what do to. I've tried a few things, but none of them seem to work. Any help would be greatly appreciated. Below is the portion of the code I am using:
dim ds1 as dataset = new Dataset()
BoardCommand.fill(ds1, "tblViewMessage")
UsersCommand.fill(ds1, "tblMainUsers")
dim dr as datarelation = new Datarelation ("MessageUserInfo", ds1.tables("tblMainUsers").columns("ID"), ds1.tables("tblViewMessage").columns("UserID"))
DS1.Relations.Add(dr)
MessageTitleDataGrid.DataSource = ds1.Tables("tblViewMessage").DefaultView
MessageDataGrid.DataSource = ds1.Tables("tblViewMessage").DefaultView
UserDataGrid.DataSource = ds1.Tables("tblMainUsers").DefaultView
Databind()