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

Edit Mode Question

2 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jibber4568
Top achievements
Rank 1
Jibber4568 asked on 10 Oct 2012, 08:55 AM
Hi Guys,

I was hoping someone might be able to point me in the right direction with a grid edit issue. I need to use a grid where all rows are always in edit mode, and then be able to retrieve the values within each rows columns.

I tried setting all rows to edit within the pre render event but this would only ever set the last row to edit mode. I managed to get all rows into edit mode as follows:

Dim i As Integer
For i = 0 To rgDbValues.PageSize - 1
    rgDbValues.EditIndexes.Add(i)
Next i

When I then need to retrieve the values in each row I am having trouble accessing the edit items.

I've tried the following code, however the editItem always returns nothing. Any ideas in what I'm doing wrong in trying to obtain the values?

For Each item As GridDataItem In rgDbValues.EditItems
       Dim editItem As GridEditFormItem = DirectCast(item.EditFormItem, GridEditFormItem)
       If editItem.IsInEditMode Then
           Dim str1 As String = TryCast(editItem("dbValue").Controls(0), TextBox).Text
 
       End If
   Next


Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Oct 2012, 09:14 AM
Hi,

Please try the following code snippet to access the edit items.

VB:
Protected Sub rgDbValues_PreRender(sender As Object, e As EventArgs)
    For Each item As GridDataItem In rgDbValues.EditItems
        If item.Edit Then
 
            Dim str1 As String = TryCast(item("dbValue").Controls(0), TextBox).Text
        End If
    Next
End Sub

Thanks,
Princy.
0
Jibber4568
Top achievements
Rank 1
answered on 10 Oct 2012, 09:37 AM
Cheers Princy
Tags
Grid
Asked by
Jibber4568
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jibber4568
Top achievements
Rank 1
Share this question
or