This is a migrated thread and some comments may be shown as answers.

grid not working on Postback for insert items

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 24 Apr 2014, 02:42 PM

I have a situation where where I need to only fired the needDatasource on a boolean statment.  It works fine for what I am doing to load the page on a querystring value.  Where the grid hiccups is when I try to use the Radgrid insert, the grid disappears becuase of the boolean statment, how can I set this statement when I postback to get at my template to insert data.

Dim fillGridNotes As Boolean = False
    Dim fillGridEmer As Boolean = False
 
    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
 
 
 
This is where I cannot ge thte grid to open to allow me to fill out the form and then postback to fill the grid.
 
 
  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
 
    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


























1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Apr 2014, 07:25 AM
Hello Kevin,

I have examined the provided code-snippet and I have noticed that in the server-side OnItemCommand event handler, in your condition you have RadGrid.PerformInsertCommandName, but for initiating an insert you should have RadGrid.InitInsertCommandName instead.

Following is the modified code for your OnItemCommand event handler:
Protected Sub myRadNotes_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)
    If e.CommandName = RadGrid.InitInsertCommandName OrElse e.CommandName = RadGrid.EditCommandName Then
        fillGridNotes = True
    End If
End Sub

Hope that helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or