Dim oRW As DataRow = CType(e.Row.DataItem,
DataRowView).Row
Jeigu GridView pakrauname duomenimis iš
LINQ, būtina sukurti klasės objektą, kad būtų aišku, kokie duomenys imami.
Kitaip - jie bus traktuojami kaip anoniminiai.
Friend Class TrainSlfView
Public Property TrID As Integer
Public Property TrDate As DateTime
Public Property Name As String
Public Property TrDuration As Decimal
Public Property TrDurationType As String
Public Property TrCost As Decimal
Public Property TrLocation As String
Public Property TrTitle As String
Public Property TrNotes As String
End Class
Duomenų pakrovimas:
Dim oTrain = (From t In oDB.TrainingSelfs
Join em In oDB.TrainingEmployeeSelfs On
em.TrID Equals t.TrID
Join emp In oDB.Employees On em.TrEmpID
Equals emp.Id
Where t.TrStatus = 0
Select New TrainSlfView With {.TrID =
t.TrID, .TrDate = t.TrDate, .Name = emp.Name, .TrDuration = t.TrDuration,
.TrDurationType = t.TrDurationType, .TrCost = t.TrCost, .TrLocation =
t.TrLocation, .TrTitle = t.TrTitle, .TrNotes = t.TrNotes}).ToList
grdTrainingView.DataSource = oTrain
grdTrainingView.DataBind()
Tada RowDataBound įvykyje TrID paimsime
taip:
Dim oRW As TrainSlfView =
CType(e.Row.DataItem, TrainSlfView)
e.Row.Attributes.Add("TrID", oRW.TrID)
hlEdit.NavigateUrl = "javascript:editRow(" &
oRW("ID") & ",'" & e.Row.ClientID &
"')"
Komentarų nėra:
Rašyti komentarą