I have a stiuation where becuase of how I load the page I need to stick in a fillGrid as boolean = false at the top of the load page to keep the NeedDataSource from firing. I then turn it to true when it can fire and rebind the grid. Everything works great up until I need to use the insert of the radgrid and then it bombs out.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim rspId As String = Request.QueryString("RSP")
If rspId = String.Empty Then
'Send to another page
Else
Dim userlogon As String = Split(Current.User.Identity.Name, "\")(1)
HFUserId.Value = GetPersId(userlogon)
HFRecruitId.Value = rspId
LoadRSP(rspId)
fillGridNotes = True
End If
End If
End Sub
Protected Sub myRadNotes_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadNotes.NeedDataSource
'Load the Notes Grid
If fillGridNotes = True Then
sql = "Select intRspNotesId, CONVERT(varchar(10), dtRSPNotesDateEntered, 111) dtNotes, strRSPNotesDesc, mn.strFullname + ' ' + ISNULL(' ' + strRank, '') LoggedBy from tblRSPNotes n LEFT JOIN MNNGPersonnel..tblMNNatPersonnel mn on " _
& "mn.intPersonnelId = n.intLoggedBy where intRSPID in (Select intRSpId from tblRSp where intRecruitId = " & HFRecruitId.Value & ") Order by dtRSPNotesDateEntered DESC"
myRadNotes.DataSource = getReader(sql)
End If
End Sub
Here is where I am having the problem though, becuase how can I set the boolean statement to true when posting back to do an insert statment on the radgrid.
Protected Sub myRadNotes_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles myRadNotes.ItemCommand
If (e.CommandName = RadGrid.PerformInsertCommandName) Then
fillGridNotes = True
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim notes As TextBox = DirectCast(editedItem.FindControl("txtNotes"), TextBox)
Dim rspId As Integer = 16533
sql = "Insert tblRSPNotes (intRSPId, dtRSpNotesDateEntered, strRSPNotesDesc, intLoggedBy) VALUES (" & rspId & ", '" & Date.Now & "', '" & sanitizeString(notes.Text) & "', " & HFUserId.Value & ")"
insertUpdateDelete(sql)
myRadNotes.Rebind()
End If
End Sub