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

Grid client side delete and existing values

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard Boarman
Top achievements
Rank 1
Richard Boarman asked on 26 Jan 2011, 04:26 PM
I am using the client side delete function on a rad grid that contains rows which include textboxes (contained in a GridTemplateColumn)
The client side function works fine, but when I try to access the current values in the textboxes after deleting a row, I am getting the original value, not the new value that is currently in the text box.
If I don't delete a row first, the correct value is read.

When the save button is clicked, this is run:
For Each itm As GridDataItem In rgIntervalSetup.Items
            If TypeOf itm Is GridDataItem Then
                Dim theID As String = itm("RecordID").Text
                Dim updatedItem As GridDataItem = CType(rgIntervalSetup.MasterTableView.FindItemByKeyValue("RecordID", Integer.Parse(theID)), GridDataItem)
                UpdateValues(updatedItem, False)
            End If
        Next
  
  
Protected Sub UpdateValues(ByVal updatedItem As GridDataItem, ByVal KeepAsTempInterval As Boolean)
        Dim txtBox As TextBox = CType(updatedItem.FindControl("txtGridIntervalName"), TextBox)
        Dim IntervalName As String = txtBox.Text
  
        Dim txtDateBox As RadDateInput = CType(updatedItem.FindControl("txtGridStartDate"), RadDateInput)
        'txtBox = CType(updatedItem.FindControl("txtGridStartDate"), TextBox)
        Dim IntervalStartDate As DateTime = txtDateBox.SelectedDate
  
        Dim theID As Integer = updatedItem.GetDataKeyValue("RecordID").ToString()
  
         
        Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(MyBase.Location.ConnectionString, _
          CommandType.StoredProcedure, _
           "EVAL2_SessionIntervalUpdate", _
           New SqlClient.SqlParameter("@SessionIntervalID", theID), _
           New SqlClient.SqlParameter("@IntervalName", IntervalName), _
           New SqlClient.SqlParameter("@IntervalStartDate", IntervalStartDate.ToUsString), _
                    New SqlClient.SqlParameter("@SessionID", mySession.ID))  
    End Sub


1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 31 Jan 2011, 06:03 PM
Hello Richard,

You are correct in your observation - when you delete the record, the text-box in the template column is gone and when the post-back request goes back to the server, RadGrid does not have another place to restore the text-box value from but the ViewState. If you need the old value, you need to persist it and retrieve it on the server (e.g. you can persist those values in a hidden field).

Hope it helps.

All the best,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Richard Boarman
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or