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

RadGrid updated textbox values

3 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Teck
Top achievements
Rank 1
Teck asked on 22 Dec 2011, 10:27 AM
Hi,

I am trying to create a batch server update for a Telerik Grid from code behind but I am unable to retrieve the latest changes in the textbox. Within the grid I set each textbox as follows and from the code behind I am forcing to enter edit Mode from the Prerender event:

<telerik:GridBoundColumn UniqueName="ContactPerson" HeaderText="Contact Person" DataField="ContactPerson" />


Also in code behind, when the user has finished committing changes on each textbox, the following event is fired when pressing a button:

Private Sub btnShipOut_Click(sender As Object, e As System.EventArgs) Handles btnShipOut.Click

 

 

For Each item As GridItem In RadGrid2.MasterTableView.Items

 

If TypeOf item Is GridEditableItem Then

 

Dim editableItem As GridDataItem = DirectCast(item, GridDataItem)

 

Dim ContactPerson As String = editableItem.Cells(2).Text

End If

 

 

Next

 

End Sub

The code works well but I am receiving the default value on each textbox instead of the updated value entered by the user before the postback. Instead, the new values are displayed in the grid after the postback.
I also tried the following code to retrieve the values but I get an OutOfRangeException error...

Dim txtbx
As TextBox = CType(editableItem("ContactPerson").Controls(0), TextBox)
Dim txtbxvalue as string = txtbx.value

 


Any help please?

Best regards.

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Dec 2011, 10:52 AM
Hello Teck,

Check the following help documentation which explains the same.
Performing Batch Updates.

-Shinu.
0
Teck
Top achievements
Rank 1
answered on 22 Dec 2011, 11:17 AM

Do you mean to implement the following code?
Is it possible to have a direct access to the edited new values without checking if an item has been changed?

Dim newValues As Hashtable = New Hashtable
     'The GridTableView will fill the values from all editable columns in the hash
     editedItem.OwnerTableView.ExtractValuesFromItem(newValues, editedItem)
     Dim changedRow As DataRow = changedRows(0)
     changedRow.BeginEdit()
     Try
         For Each entry As DictionaryEntry In newValues
             changedRow(CType(entry.Key, String)) = entry.Value
         Next
         changedRow.EndEdit()
     Catch Ex As Exception
         changedRow.CancelEdit()
     End Try
0
Teck
Top achievements
Rank 1
answered on 22 Dec 2011, 07:57 PM
I just find the solution to my problem. My code was working ok only if the grid is edited Inline. When I choose "editForms" option I cannot access new values...
Tags
Grid
Asked by
Teck
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Teck
Top achievements
Rank 1
Share this question
or