Private Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
Dim strError As String = ""
Try
If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then
'get a reference to the control
Dim Placeholder1 As PlaceHolder = CType(e.Item.FindControl("Placeholder1"), PlaceHolder)
'get a reference to a key field
Dim intMasterNumber As Int32 = RadGrid1.MasterTableView.DataKeyValues(e.Item.ItemIndex)("intMasterNumber")
'lookup the items that we're going to add to the grid
Dim oDT As New DataTable
oDT = SPs.fp_FPTakeoff3_SEL_byMasterNumber(intMasterNumber, Session("ConnectionString")).getTable
'loop through the datatable
For Each oDataRow As DataRow In oDT.Rows
'create a new link button
Dim lnk As New LinkButton
'set its properties
lnk.Text = String.Format("Takeoff {0}", oDataRow("TakeoffID"))
lnk.CommandArgument = oDataRow("TakeoffID")
'add a handler for the click event
AddHandler lnk.Click, AddressOf LinkHandler
'add the control to the placeholder
Placeholder1.Controls.Add(lnk)
'add a 'space', so the links don't touch each other
Dim lit As New Literal
lit.Text = " "
Placeholder1.Controls.Add(lit)
Next
End If
Catch ex As ThreadAbortException
Catch ex As Exception
ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
Me.lblError.Text = ex.Message
End Try
End Sub
Sub LinkHandler(sender As Object, e As EventArgs)
Dim strError As String = ""
Try
'coerse the sender to a LinkButton
Dim lnk As LinkButton = CType(sender, LinkButton)
'store the value
Session("TakeoffID") = lnk.CommandArgument
'redirect
Response.Redirect(String.Format("Takeoff4.aspx?Path={0}", Session("Path")))
Catch ex As ThreadAbortException
Catch ex As Exception
ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
Me.lblError.Text = ex.Message
End Try
End Sub