User126014556 posted
I have the GridView the produces the following rows:
Column0 |
Column1 |
Column2 |
Group A |
Report A |
Link 1 |
Group C |
Report A |
Link 1 |
Is it possible to hide a row in gridview when a repeated value occurs in Column1? In order to produce the below result:
Column0 |
Column1 |
Column2 |
Group A |
Report A |
Link 1 |
Code page:
Imports System.Data.SqlClient
Imports System.Web.Configuration
Public Class _default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim hLink As HyperLink = TryCast(e.Row.FindControl("hLnk"), HyperLink)
Dim lblApp As Label = TryCast(e.Row.FindControl("lblAppName"), Label)
Dim lblGrp As Label = TryCast(e.Row.FindControl("lblGroup"), Label)
Dim lblCod As Label = TryCast(e.Row.FindControl("lblCode"), Label)
Try
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Visible = IsInGroup(lblGrp.Text.Trim())
End If
Catch ex As Exception
End Try
End Sub
Public Function IsInGroup(ByVal GroupName As String) As Boolean
Dim MyIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim MyPrincipal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(MyIdentity)
Return MyPrincipal.IsInRole(GroupName)
End Function
End Class
I apprciate any help, thanks in advance.