locked
Convert from Gridview code to Repeater Code RRS feed

  • Question

  • User151513110 posted

    Hi,

    I have using Repeater control in my project and I will place subtotal for each group data (add new row) . I tried to search SubTotal in repeater control .  but still I not yet get the code, eventually Gridview control we can do it.  however I have using repeater in my project.   hence if its possible to convert gridview code to repeater code .

    Protected Sub OnRowCreated(sender As Object, e As GridViewRowEventArgs)
        subTotal = 0
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim dt As DataTable = TryCast(e.Row.DataItem, DataRowView).DataView.Table
            Dim orderId As Integer = Convert.ToInt32(dt.Rows(e.Row.RowIndex)("OrderID"))
            total += Convert.ToDecimal(dt.Rows(e.Row.RowIndex)("Price"))
            If orderId <> currentId Then
                If e.Row.RowIndex > 0 Then
                    For i As Integer = subTotalRowIndex To e.Row.RowIndex - 1
                        subTotal += Convert.ToDecimal(GridView1.Rows(i).Cells(2).Text)
                    Next
                    Me.AddTotalRow("Sub Total", subTotal.ToString("N2"))
                    subTotalRowIndex = e.Row.RowIndex
                End If
                currentId = orderId
            End If
        End If
    End Sub
     
    Private Sub AddTotalRow(labelText As String, value As String)
        Dim row As New GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal)
        row.BackColor = ColorTranslator.FromHtml("#F9F9F9")
        'Empty Cell
        row.Cells.AddRange(New TableCell(2) {New TableCell(), New TableCell() With { _
          .Text = labelText, _
          .HorizontalAlign = HorizontalAlign.Right _
        }, New TableCell() With { _
          .Text = value, _
          .HorizontalAlign = HorizontalAlign.Right _
        }})
     
        GridView1.Controls(0).Controls.Add(row)
    End Sub
    I would expecting the results in repeater control.....
    
    Protected Sub ItemCreated(sender As Object, e As RepeaterItemEventArgs)
        
    End Sub
     
    Private Sub AddTotalRow(labelText As String, value As String)
       
    End Sub
    
    Any one please suggest me.




    Tuesday, June 14, 2016 3:03 AM

Answers

All replies