Data Relation Help!!!

L

Lerp

Hi all,

I have this sub that is called on itemdatabound of my datagrid that is
supposed to retrieve client and employee first and last names and substitute
the existing labels text property (ids) with the newly created names.
My problem is the referencing the field in the data relation. If someone
could help that would be really cool.

Cheers, Lerp :)


'DATA RELATION CODE FROM HEAD
Dim datrela as New DataRelation("ClientBookings",
ds.Tables("CLIENT").Columns("clientid"),
ds.Tables("BOOKING").Columns("clientid"))
ds.Relations.Add(datrela)

Dim datrelb as New DataRelation("EmployeeBookings",
ds.Tables("EMPLOYEE").Columns("empid"),
ds.Tables("BOOKING").Columns("empid"))
ds.Relations.Add(datrelb)




'MY SUB - SUBSTITUTE THE CLIENT AND EMPLOYEE ID FIELDS WITH THEIR ACTUAL
NAMES USING DATA RELATIONS
Sub dgBookings_OnItemDataBound(sender As Object, e As DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then

'RETRIEVE THE LABEL CONTROLS FOR THE CURRENT ITEM
Dim clientnamelabel As Label = e.Item.FindControl("clientnamelabel")
Dim employeenamelabel As Label = e.Item.FindControl("employeenamelabel")

Dim curClientName as String
Dim curEmpName as String

****** SUBSTITUTE HERE
curEmpName =
ds.Tables("EMPLOYEE").Rows(0).GetParentRow("EmployeeBookings")("fname") & "
" & ds.Tables("EMPLOYEE").Rows(0).GetParentRow("EmployeeBookings")("lname")
curClientName =
ds.Tables("CLIENT").Rows(0).GetParentRow("ClientBookings")("fname") & " " &
ds.Tables("CLIENT").Rows(0).GetParentRow("ClientBookings")("lname")

clientnamelabel.Text = curClientName
employeenamelabel.Text = curEmpName

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top