Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ...........


I have a doubt on gridview rowdatabound event.... i bind a datatable with five rows to a gridview, and gridview shows all five rows correctly only when i do not include the rowdatabound event's action, otherwise it makes 3rd and 4th cells be empty. here is my code

C#
Protected Sub FolioDataGrid_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles FolioDataGrid.RowDataBound
For Each row As GridViewRow In FolioDataGrid.Rows
                'CR 20303, 20206  Starts.
                Dim strTableCellKRACDesc As TableCell = row.Cells(2)
                Dim strTableCellKRACode As TableCell = row.Cells(3)
                'Dim strTableCellKRACDesc As TableCell = row.Cells(4)
                Dim lblKYCStatus As Label
                lblKYCStatus = CType(row.Cells(4).FindControl("lblKYCStatus"), Label)
                ' CR 20346 Starts.
                If strTableCellKRACode.Text = "51" Then
                    strTableCellKRACDesc.Text = "KYC REGISTERED - AADHAR eKYC - OTP"
                    FolioDataGrid.Columns(3).Visible = True
                    FolioDataGrid.Columns(4).Visible = False
                    intColvisibility = 1
                ElseIf strTableCellKRACode.Text = "52" Then
                    strTableCellKRACDesc.Text = "KYC REGISTERED - AADHAR eKYC - BIOMETRIC"
                    FolioDataGrid.Columns(3).Visible = True
                    FolioDataGrid.Columns(4).Visible = False
                    intColvisibility = 1
                Else
                    ' CR 20346 Ends.
                    If (strTableCellKRACode.Text).Trim() <> String.Empty AndAlso lblKYCStatus.Text <> String.Empty Then
                        Dim strTempKRADesc As String = findKRADescription(strTableCellKRACode.Text.Trim(), lblKYCStatus.Text)
                        If strTempKRADesc <> String.Empty Then
                            strTableCellKRACDesc.Text = strTempKRADesc
                            FolioDataGrid.Columns(3).Visible = True
                            FolioDataGrid.Columns(4).Visible = False
                            intColvisibility = 1
                        Else
                            'Existing logic continues...
                            If intColvisibility <> 1 Then
                                FolioDataGrid.Columns(3).Visible = False
                                FolioDataGrid.Columns(4).Visible = False
                            End If

                        End If
                    Else
                        'Existing logic continues...
                        If intColvisibility <> 1 Then
                            FolioDataGrid.Columns(3).Visible = False
                            FolioDataGrid.Columns(4).Visible = False
                        End If
                    End If  
                End If 
                'CR 20303, 20206  Ends.
            Next
        Catch ex As Exception
            Throw New ApplicationException(ex.Message)
        End Try 
    End Sub 
End Sub


please anyone suggest me , what i did wrong in my code and thanks in advance...
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900