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

How to populate "custom" text into ChildRadGridView

1 Answer 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hkdave95
Top achievements
Rank 2
hkdave95 asked on 22 May 2008, 06:45 AM
Hi

How do I use RowFormatting to populate "custom" text into a ChildRadGridView ?

The following code populates the MasterGridView properly but my commented out code causes the program to fall over in a heap.

Private Sub rgvInvoices_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles rgvInvoices.RowFormatting  
        Dim loUserRow As _the_dl_outletDataSet.UsersRow = Me._the_dl_outletDataSet.Users.FindByU_nId(CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_U_nId").Value, System.Int64))  
        If loUserRow IsNot Nothing Then  
            CType(e.RowElement.RowInfo.Cells("sCustomerName").CellElement, Telerik.WinControls.UI.GridCellElement).Text = loUserRow.U_sLastName & ", " & loUserRow.U_sFirstName  
        End If  
        CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text = CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress1").Value) & vbNewLine  
        If String.IsNullOrEmpty(CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress2").Value)) Then  
            CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress2").Value) & vbNewLine  
        End If  
        CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCity").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCounty").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingPostCode").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCountry").Value)  
        Dim loDeliveryAddressRow As _the_dl_outletDataSet.DeliveryAddressesRow = Me._the_dl_outletDataSet.DeliveryAddresses.FindByDA_nId(CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_DA_nId").Value, System.Int64))  
        If loDeliveryAddressRow IsNot Nothing Then  
            CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text = loDeliveryAddressRow.DA_sAddress1 & vbNewLine  
            If loDeliveryAddressRow.IsDA_sAddress2Null Then  
                CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= loDeliveryAddressRow.DA_sAddress2 & vbNewLine  
            End If  
            CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= loDeliveryAddressRow.DA_sCity & vbNewLine & loDeliveryAddressRow.DA_sCounty & vbNewLine & loDeliveryAddressRow.DA_sPostCode & vbNewLine & loDeliveryAddressRow.DA_sCountry  
        End If  
        'Select Case CType(sender, Telerik.WinControls.UI.RadGridView).Name  
        '    Case "rgvInvoices"  
        '    Case "rgvAuditTrail"  
        '        Select Case CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("AT_nType").Value, _Enum.AuditTrailTypes)  
        '            Case AuditTrailTypes.OrderPlaced  
        '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Order Placed" 
        '            Case AuditTrailTypes.OrderCancelled  
        '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Order Cancelled" 
        '            Case AuditTrailTypes.PaymentUnverified  
        '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Payment unverified" 
        '            Case AuditTrailTypes.PaymentVerified  
        '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Payment verified" 
        '            Case Else  
        '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Unknown Audit Trail entry" 
        '        End Select  
        'End Select  
    End Sub 

Any ideas ?

Kind Regards

David

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 26 May 2008, 01:08 PM
Hi hkdave95,

Thank you for writing.

In general, there is no problem with your approach. You should use the CellFormating instead of the RowFormating event, because you need to edit the value of every cell. CellFormating is fired for all visible cells in the RadGridView and you should use it when setting custom cell formatting, value or appearance.

If you need additional assistance, do not hesitate to contact me again.

Greetings,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
hkdave95
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
Share this question
or