I had to put in a Boolean value on my grid to trigger it in certain situations to fill or not. however with the gird features of insert and edit turned on it will not show them on postback so I cannot do insert or edits with template editform's. I know I have resolved this long ago but can't find location or my old ticket.
It only happens when I click on edit form or insert to grid and I get blank grid line, but if I hit refresh again there is the edit or insert information, so I know it has to do Boolean statement.
Dim fundGrid As Boolean = False
Protected Sub myFundGrid_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles myFundGrid.ItemCommand
If (e.CommandName = "Archive") Then
Dim fundId As Integer = e.CommandArgument
sql = "Update Drat_FundSource set bitArchive = 1 where intFundID = " & fundId
insertUpdateDelete(sql)
fundGrid = True
myFundGrid.Rebind()
End If
If (e.CommandName = RadGrid.PerformInsertCommandName AndAlso e.Item.OwnerTableView.Name = "FundGrid") Then
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim source As DropDownList = DirectCast(editedItem.FindControl("ddlSource"), DropDownList)
Dim pgm As TextBox = DirectCast(editedItem.FindControl("txtPGm"), TextBox)
Dim eor As TextBox = DirectCast(editedItem.FindControl("txtEOR"), TextBox)
Dim mdep As TextBox = DirectCast(editedItem.FindControl("txtMDEP"), TextBox)
Dim ams As TextBox = DirectCast(editedItem.FindControl("txtAMSCOS"), TextBox)
sql = "Insert Drat_FundSource (intSourceId, strPGMCDNum,strEORNum, strMDepNum, strAMSCOSNum, dtEntered, intEnteredBy) VALUES (" & source.SelectedValue & ", '" & sanitizeString(pgm.Text.ToUpper) & "', " _
& "'" & sanitizeString(eor.Text.ToUpper) & "', '" & sanitizeString(mdep.Text.ToUpper) & "', '" & sanitizeString(ams.Text.ToUpper) & "', '" & Date.Now & "', " & GetUserId() & ")"
insertUpdateDelete(sql)
fundGrid = True
myFundGrid.Rebind()
End If
If (e.CommandName = RadGrid.UpdateCommandName AndAlso e.Item.OwnerTableView.Name = "FundGrid") Then
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim fundId As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID")
Dim source As DropDownList = DirectCast(editedItem.FindControl("ddlSource"), DropDownList)
Dim pgm As TextBox = DirectCast(editedItem.FindControl("txtPGm"), TextBox)
Dim eor As TextBox = DirectCast(editedItem.FindControl("txtEOR"), TextBox)
Dim mdep As TextBox = DirectCast(editedItem.FindControl("txtMDEP"), TextBox)
Dim ams As TextBox = DirectCast(editedItem.FindControl("txtAMSCOS"), TextBox)
sql = "Update Drat_FundSource set intSourceId = " & source.SelectedValue & ", strPGMCDNum = '" & sanitizeString(pgm.Text.ToUpper) & "', strEORNum = '" & sanitizeString(eor.Text.ToUpper) & "', " _
& "strMDepNum = '" & sanitizeString(mdep.Text.ToUpper) & "', strAMSCOSNum = '" & sanitizeString(ams.Text.ToUpper) & "' where intFundId = " & fundId
insertUpdateDelete(sql)
fundGrid = True
myFundGrid.Rebind()
End If
End Sub
Protected Sub myFundGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myFundGrid.NeedDataSource
If fundGrid = True Then
Dim sqlwhere As String
If cbhistory.Checked = True Then
sqlwhere = String.Empty
Else
sqlwhere = " where bitArchive IS NULL"
End If
sql = "Select ds.intFundId ID, intSourceId, CASE WHEN ds.intSourceId = 1 then 'FEDERAL' ELSE 'STATE' END SOURCE, ds.strPGMCDNum PGMCD, ds.strEORNum EOR, ds.strMDepNum MDEP, ds.strAmscosNum AMSCOS, " _
& "Convert(varchar(10), ds.dtEntered, 111) DATE, mn.strFullName + ' \ ' + strRank NAME from Drat_FundSource ds INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel mn on mn.intPersonnelId = intEnteredBy " _
& sqlwhere
myFundGrid.DataSource = getData(sql)
End If
End Sub