Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Updating multiple rows from one form
posted

Hi,

I am using NetAdvantage .Net 2007 Vol 2 for ASP.Net.  I have a databound WebGrid that has an unbound checkbox column as the first column to  select one or more rows to update.  Once rows have been selected, the user will click a button to bring up a form/dialog to select values to update all the selected rows with those values.  The idea is to avoid having the user manually update each individual row, since the data is going be repetitive.

Has anyone done something similar or have any ideas on the best way to implement this?    Thanks

 

Parents
No Data
Reply
  • 8680
    posted

    I've done exactly that, using the following code.  One pitfall is the fact that Grid.Rows contains rows for all grouping levels and all bands.  To get around this, I implemented a recursive function that processed only leaf-node rows.

    'Traverses an UltraWebGrid.RowsCollection, looking
    'for checked boxes in one column, and adding
    'corresponding values from another column to a
    'results collection. Processes only leaf node rows.
    Private Sub ScanRowsCollection( _
                   
    ByRef rRows As RowsCollection, _
                   
    ByVal vCheckboxColumnKey As String, _
                   
    ByVal vValueColumnKey As String, _
                   
    ByRef rValues As Collection)

        Dim lResult As New Collection
       
    Dim lCheckCell As UltraGridCell
       
    Dim lValueCell As UltraGridCell

        For Each lRow As UltraGridRow In rRows

            If lRow.HasChildRows Then 'only scan lowest band

                ScanRowsCollection(lRow.Rows, vCheckboxColumnKey, _
                                                vValueColumnKey, rValues)

            Else

                lCheckCell = lRow.Cells.FromKey(vCheckboxColumnKey)
                lValueCell = lRow.Cells.FromKey(vValueColumnKey)

                If lCheckCell IsNot Nothing And lValueCell IsNot Nothing Then
                    If CBool(lCheckCell.Value) Then
                        'process checked row here
                    End If
                End If

            End If

        Next

    End Sub


    HTH
Children