ASP DOT NET

Tuesday, September 17, 2019

How to Implement check all checkbox functionality in ASP.Net GridView control using JavaScript

****************************ASP.NET CODE*********************************


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ImplementsCheckBoxesUsingJS.aspx.vb" Inherits="WebApplication1.ImplementsCheckBoxesUsingJS" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type = "text/javascript">

function Check_Click(objRef)
{
    //Get the Row based on checkbox
    var row = objRef.parentNode.parentNode;
    if(objRef.checked)
    {
        //If checked change color to Aqua
        row.style.backgroundColor = "aqua";
    }
    else
    {   
        //If not checked change back to original color
        if(row.rowIndex % 2 == 0)
        {
           //Alternating Row Color
           row.style.backgroundColor = "#C2D69B";
        }
        else
        {
           row.style.backgroundColor = "white";
        }
    }
    //Get the reference of GridView
    var GridView = row.parentNode;
    //Get all input elements in Gridview
    var inputList = GridView.getElementsByTagName("input");
    for (var i=0;i<inputList.length;i++)
    {
        //The First element is the Header Checkbox
        var headerCheckBox = inputList[0];
        //Based on all or none checkboxes
        //are checked check/uncheck Header Checkbox
        var checked = true;
        if(inputList[i].type == "checkbox" && inputList[i] != headerCheckBox)
        {
            if(!inputList[i].checked)
            {
                checked = false;
                break;
            }
        }
    }
    headerCheckBox.checked = checked;   
}
</script>
<script type = "text/javascript">
function checkAll(objRef)
{
    var GridView = objRef.parentNode.parentNode.parentNode;
    var inputList = GridView.getElementsByTagName("input");
    for (var i=0;i<inputList.length;i++)
    {
        //Get the Cell To find out ColumnIndex
        var row = inputList[i].parentNode.parentNode;
        if(inputList[i].type == "checkbox"  && objRef != inputList[i])
        {
            if (objRef.checked)
            {
                //If the header checkbox is checked
                //check all checkboxes
                //and highlight all rows
                row.style.backgroundColor = "aqua";
                inputList[i].checked=true;
            }
            else
            {
                //If the header checkbox is checked
                //uncheck all checkboxes
                //and change rowcolor back to original
                if(row.rowIndex % 2 == 0)
                {
                   //Alternating Row Color
                   row.style.backgroundColor = "#C2D69B";
                }
                else
                {
                   row.style.backgroundColor = "white";
                }
                inputList[i].checked=false;
            }
        }
    }
}
</script> 
<script type = "text/javascript">
function MouseEvents(objRef, evt)
{
    var checkbox = objRef.getElementsByTagName("input")[0];
   if (evt.type == "mouseover")
   {
        objRef.style.backgroundColor = "orange";
   }
   else
   {
        if (checkbox.checked)
        {
            objRef.style.backgroundColor = "aqua";
        }
        else if(evt.type == "mouseout")
        {
            if(objRef.rowIndex % 2 == 0)
            {
               //Alternating Row Color
               objRef.style.backgroundColor = "#C2D69B";
            }
            else
            {
               objRef.style.backgroundColor = "white";
            }
         }
   }
}

</script>
</head>
<body>
    <form id="form1" runat="server">
        <div align="center">
            <asp:GridView ID="GridView1" runat="server" HeaderStyle-CssClass="header"
                AutoGenerateColumns="false" Font-Names="Arial"
                OnRowDataBound="RowDataBound"
                Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="EmpId" DataField="EmpId" />
                    <asp:BoundField HeaderText="EmpName" DataField="Emp_Name" />
                    <asp:BoundField HeaderText="EmpAddress" DataField="Emp_Address" />
                    <asp:BoundField HeaderText="EmpDept" DataField="Emp_Department" />
                    <%--<asp:BoundField HeaderText="Salary" DataField="Salary" />--%>
                    <asp:TemplateField HeaderText="Salary">
                        <ItemTemplate>
                            <asp:Label ID="lblListPrice" runat="server" Text='<%#Eval("Salary")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="OtherAllownce">
                        <ItemTemplate>
                            <asp:Label ID="lblOtherAllownce" runat="server" Text='<%#Eval("OtherAllownce")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    </form>
</body>

</html>
*****************************VB.NET CODE*************************

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Public Class ImplementsCheckBoxesUsingJS
    Inherits System.Web.UI.Page
    Private con As SqlConnection
    Private adap As SqlDataAdapter
    Private dt As DataTable
    Dim strConnString As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGridview()
        End If
    End Sub
    Protected Sub RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.Attributes.Add("onmouseover", "MouseEvents(this, event)")
            e.Row.Attributes.Add("onmouseout", "MouseEvents(this, event)")
        End If
    End Sub
    Public Sub New()
        strConnString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
    End Sub
    Protected Sub BindGridview()
        adap = New SqlDataAdapter("select * from EmployeeInformation", strConnString)
        dt = New DataTable()
        adap.Fill(dt)
        GridView1.DataSource = dt
        GridView1.DataBind()
    End Sub
End Class

**************************Table Descriptions***************************************

CREATE TABLE [dbo].[EmployeeInformation](
[EmpId] [int] NULL,
[Emp_Name] [varchar](max) NULL,
[Emp_Address] [nvarchar](max) NULL,
[Emp_Department] [varchar](max) NULL,
[Salary] [money] NULL,
[OtherAllownce] [money] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


How to create new grid select gridview rows using asp.net

****************************ASP.NET CODE*********************************

<form id="form1" runat="server">
        <div class="card">
            <table>
                <tr>
                    <td>
                        
                <asp:Label ID="lblTotalCaption" runat="server" Visible="false">Total Salary:</asp:Label>
              
            
                    </td>
                    <td>
                          <asp:Label ID="lblTotal" runat="server"></asp:Label>
                    </td>
                    <td>
                         <asp:Label ID="lblTotalAllownce" runat="server" Visible="false">Total Allownce:</asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblTotaAllownce" runat="server"></asp:Label>
                    </td>
                    <td>

                    </td>
                </tr>

            </table>
           
            <br />
            <asp:GridView ID="gvEmpInfo" AutoGenerateColumns="False" CellPadding="4" runat="server"
                BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkbox" runat="server" AutoPostBack="true" OnCheckedChanged="ChckedChanged"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="EmpId" DataField="EmpId" />
                    <asp:BoundField HeaderText="EmpName" DataField="Emp_Name" />
                    <asp:BoundField HeaderText="EmpAddress" DataField="Emp_Address" />
                    <asp:BoundField HeaderText="EmpDept" DataField="Emp_Department" />
                    <%--<asp:BoundField HeaderText="Salary" DataField="Salary" />--%>
                    <asp:TemplateField HeaderText="Salary">
                        <ItemTemplate>
                            <asp:Label ID="lblListPrice" runat="server" Text='<%#Eval("Salary")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="OtherAllownce">
                        <ItemTemplate>
                            <asp:Label ID="lblOtherAllownce" runat="server" Text='<%#Eval("OtherAllownce")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                <HeaderStyle BackColor="#003399" Font-Bold="true" ForeColor="#CCCCFF" />
                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                <RowStyle BackColor="White" ForeColor="#003399" />
                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                <SortedDescendingHeaderStyle BackColor="#002876" />
            </asp:GridView>
            <br />
            <b>OnCheckedChanged Event Fired on Gridview</b>
            <asp:GridView ID="gvMovedRows" AutoGenerateColumns="False" CellPadding="4" runat="server" ForeColor="#333333" GridLines="None">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:BoundField HeaderText="EmpId" DataField="EmpId" />
                    <asp:BoundField HeaderText="EmpName" DataField="Emp_Name" />
                    <asp:BoundField HeaderText="EmpAddress" DataField="Emp_Address" />
                    <asp:BoundField HeaderText="EmpDept" DataField="Emp_Department" />
                    <%--<asp:BoundField HeaderText="Salary" DataField="Salary" />--%>
                    <asp:TemplateField HeaderText="Salary">
                        <ItemTemplate>
                            <asp:Label ID="lblListPrice" runat="server" Text='<%#Eval("Salary", "{0:c}")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
        </div>

    </form>

*********************************vb.net code**********************************


Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Public Class CheckBoxesCalkulations
    Inherits System.Web.UI.Page
    Private con As SqlConnection
    Private adap As SqlDataAdapter
    Private dt As DataTable
    Dim strConnString As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGridview()
        End If
    End Sub
    Public Sub New()
        strConnString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
    End Sub
    Protected Sub BindGridview()
        adap = New SqlDataAdapter("select * from EmployeeInformation", strConnString)
        dt = New DataTable()
        adap.Fill(dt)
        gvEmpInfo.DataSource = dt
        gvEmpInfo.DataBind()
    End Sub
    Protected Sub ChckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Dim count As Integer = 0
            Dim totalSalary As Decimal = 0
            Dim totalOther As Decimal = 0
            lblTotal.Text = ""
            lblTotaAllownce.Text = ""
            lblTotalCaption.Visible = False
            lblTotalAllownce.Visible = False
            For Each rw As GridViewRow In gvEmpInfo.Rows
                Dim chkBx As CheckBox = CType(rw.FindControl("chkbox"), CheckBox)

                If chkBx.Checked Then
                    count += 1
                    Dim Salary As Decimal = Convert.ToDecimal((CType(rw.FindControl("lblListPrice"), Label)).Text)
                    Dim OtherAllownce As Decimal = Convert.ToDecimal((CType(rw.FindControl("lblOtherAllownce"), Label)).Text)
                    totalSalary = Convert.ToDecimal((totalSalary + Convert.ToDecimal(Salary)))
                    totalOther = Convert.ToDecimal((totalOther + Convert.ToDecimal(OtherAllownce)))
                    chkBx.Checked = True
                    lblTotal.Text = totalSalary.ToString()
                    lblTotaAllownce.Text = totalOther.ToString
                    lblTotalCaption.Visible = True
                    lblTotalAllownce.Visible = True

                End If
            Next
        Catch ex As Exception

        End Try


        GetSelectedRows()
        BindSecondGrid()
    End Sub
    Protected Sub BindSecondGrid()
        Dim dt As DataTable = CType(ViewState("EmpDetails"), DataTable)
        gvMovedRows.DataSource = dt
        gvMovedRows.DataBind()
    End Sub
    Private Sub GetSelectedRows()
        Dim dt As DataTable

        If ViewState("EmpDetails") IsNot Nothing Then
            dt = CType(ViewState("EmpDetails"), DataTable)
        Else
            dt = CreateTable()
        End If

        For i As Integer = 0 To gvEmpInfo.Rows.Count - 1
            Dim chk As CheckBox = CType(gvEmpInfo.Rows(i).Cells(0).FindControl("chkbox"), CheckBox)

            If chk.Checked Then
                dt = MoveRows(gvEmpInfo.Rows(i), dt)
            Else
                dt = RemoveRow(gvEmpInfo.Rows(i), dt)
            End If
        Next

        ViewState("EmpDetails") = dt
    End Sub
    Private Function CreateTable() As DataTable
        Dim dt As DataTable = New DataTable()
        dt.Columns.Add("EmpId")
        dt.Columns.Add("Emp_Name")
        dt.Columns.Add("Emp_Address")
        dt.Columns.Add("Emp_Department")
        dt.Columns.Add("Salary")
        dt.AcceptChanges()
        Return dt
    End Function
    Private Function MoveRows(ByVal gvRow As GridViewRow, ByVal dt As DataTable) As DataTable
        Dim dr As DataRow() = dt.[Select]("EmpId = '" & gvRow.Cells(1).Text & "'")

        If dr.Length <= 0 Then
            dt.Rows.Add()
            Dim rowscount As Integer = dt.Rows.Count - 1
            dt.Rows(rowscount)("EmpId") = gvRow.Cells(1).Text
            dt.Rows(rowscount)("Emp_Name") = gvRow.Cells(2).Text
            dt.Rows(rowscount)("Emp_Address") = gvRow.Cells(3).Text
            dt.Rows(rowscount)("Emp_Department") = gvRow.Cells(4).Text
            dt.Rows(rowscount)("Salary") = gvRow.Cells(5).Text
            dt.AcceptChanges()
        End If

        Return dt
    End Function
    Private Function RemoveRow(ByVal gvRow As GridViewRow, ByVal dt As DataTable) As DataTable
        Dim dr As DataRow() = dt.[Select]("EmpId = '" & gvRow.Cells(1).Text & "'")
        If dr.Length > 0 Then
            dt.Rows.Remove(dr(0))
            dt.AcceptChanges()
        End If
        Return dt
    End Function

End Class

*************************Table ***********************************

CREATE TABLE [dbo].[EmployeeInformation](
[EmpId] [int] NULL,
[Emp_Name] [varchar](max) NULL,
[Emp_Address] [nvarchar](max) NULL,
[Emp_Department] [varchar](max) NULL,
[Salary] [money] NULL,
[OtherAllownce] [money] NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]





Saturday, September 14, 2019

Salary calculation on check changed events

-------------------------------------------------Asp.net code----------------------------------------------------

<form id="form1" runat="server">
    <div class="card">
             <table>
                <tr>
                    <td>
                        
                <asp:Label ID="lblTotalCaption" runat="server" Visible="false">Total Salary:</asp:Label>
              
            
                    </td>
                    <td>
                          <asp:Label ID="lblTotal" runat="server"></asp:Label>
                    </td>
                    <td>
                         <asp:Label ID="lblTotalAllownce" runat="server" Visible="false">Total Allownce:</asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblTotaAllownce" runat="server"></asp:Label>
                    </td>
                    <td>

                    </td>
                </tr>

            </table>
            <br />
            <asp:GridView ID="gvEmpInfo" AutoGenerateColumns="False" CellPadding="4" runat="server"
                BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkbox" runat="server" AutoPostBack="true" OnCheckedChanged="ChckedChanged"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="EmpId" DataField="EmpId" />
                    <asp:BoundField HeaderText="EmpName" DataField="Emp_Name" />
                    <asp:BoundField HeaderText="EmpAddress" DataField="Emp_Address" />
                    <asp:BoundField HeaderText="EmpDept" DataField="Emp_Department" />
                    <%--<asp:BoundField HeaderText="Salary" DataField="Salary" />--%>
                    <asp:TemplateField HeaderText="Salary">
                        <ItemTemplate>
                            <asp:Label ID="lblListPrice" runat="server" Text='<%#Eval("Salary")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField HeaderText="OtherAllownce">
                        <ItemTemplate>
                            <asp:Label ID="lblOtherAllownce" runat="server" Text='<%#Eval("OtherAllownce")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                <HeaderStyle BackColor="#003399" Font-Bold="true" ForeColor="#CCCCFF" />
                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                <RowStyle BackColor="White" ForeColor="#003399" />
                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                <SortedDescendingHeaderStyle BackColor="#002876" />
            </asp:GridView>
    
    </div>
    </form>


-------------------------------------------------------C#.net code-----------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace ProjectAspCSharp
{
    public partial class GridViewSalaryCalculations : System.Web.UI.Page
    {
        SqlConnection con;
        SqlDataAdapter adap;
        DataTable dt;
        String strConnString;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGridview();
            }
        }
        public GridViewSalaryCalculations()
        {
            //strConnString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString();
            strConnString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
        }
        protected void BindGridview()
        {
            adap = new SqlDataAdapter("select * from EmployeeInformation", strConnString);
            dt = new DataTable();
            adap.Fill(dt);
            gvEmpInfo.DataSource = dt;
            gvEmpInfo.DataBind();
        }
        protected void ChckedChanged(object sender, EventArgs e)
        {           
            try
            {
                int count = 0;
                Decimal totalSalary = 0;
                Decimal totalOther = 0;
               
                lblTotal.Text = "";
                lblTotaAllownce.Text = "";
                lblTotalCaption.Visible = false;
                lblTotalAllownce.Visible = false;
                foreach (GridViewRow rw in gvEmpInfo.Rows)
                {
                    CheckBox chkBx = (CheckBox)rw.FindControl("chkbox");
                    if (chkBx.Checked)
                    {
                        count++;
                        Decimal Salary = Convert.ToDecimal(((Label)rw.FindControl("lblListPrice")).Text);
                        Decimal OtherAllownce = Convert.ToDecimal(((Label)rw.FindControl("lblOtherAllownce")).Text);
                        totalSalary = Convert.ToDecimal((totalSalary + Convert.ToDecimal(Salary)));
                        totalOther = Convert.ToDecimal((totalOther + Convert.ToDecimal(OtherAllownce)));
                        chkBx.Checked = true;                       
                        lblTotal.Text = totalSalary.ToString();
                        lblTotaAllownce.Text = totalOther.ToString();
                        lblTotalCaption.Visible = true;
                        lblTotalAllownce.Visible = true;
                    }
                }              
            }
            catch (Exception ex)
            {

            }
        }
    }

}

----------------------------------------------vb.net code------------------------------------------------------



Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Public Class CheckBoxesCalkulations
    Inherits System.Web.UI.Page
    Private con As SqlConnection
    Private adap As SqlDataAdapter
    Private dt As DataTable
    Dim strConnString As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGridview()
        End If
    End Sub
    Public Sub New()
        strConnString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
    End Sub
    Protected Sub BindGridview()
        adap = New SqlDataAdapter("select * from EmployeeInformation", strConnString)
        dt = New DataTable()
        adap.Fill(dt)
        gvEmpInfo.DataSource = dt
        gvEmpInfo.DataBind()
    End Sub
    Protected Sub ChckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Dim count As Integer = 0
            Dim totalSalary As Decimal = 0
            Dim totalOther As Decimal = 0
            lblTotal.Text = ""
            lblTotaAllownce.Text = ""
            lblTotalCaption.Visible = False
            lblTotalAllownce.Visible = False
            For Each rw As GridViewRow In gvEmpInfo.Rows
                Dim chkBx As CheckBox = CType(rw.FindControl("chkbox"), CheckBox)

                If chkBx.Checked Then
                    count += 1
                    Dim Salary As Decimal = Convert.ToDecimal((CType(rw.FindControl("lblListPrice"), Label)).Text)
                    Dim OtherAllownce As Decimal = Convert.ToDecimal((CType(rw.FindControl("lblOtherAllownce"), Label)).Text)
                    totalSalary = Convert.ToDecimal((totalSalary + Convert.ToDecimal(Salary)))
                    totalOther = Convert.ToDecimal((totalOther + Convert.ToDecimal(OtherAllownce)))
                    chkBx.Checked = True
                    lblTotal.Text = totalSalary.ToString()
                    lblTotaAllownce.Text = totalOther.ToString
                    lblTotalCaption.Visible = True
                    lblTotalAllownce.Visible = True

                End If
            Next
        Catch ex As Exception

        End Try


        '    GetSelectedRows()
        '    BindSecondGrid()

    End Sub
End Class

How to to select duplicate rows from sql server?

 SELECT * FROM Recruitment WHERE Email IN (SELECT Email FROM Recruitment GROUP BY Email HAVING COUNT(*) > 1); WITH CTE AS (     SELECT   ...