HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Transer">
<ItemTemplate>
<asp:ImageButton ImageUrl="Images/transfer.png" AlternateText="Transfer" OnClick="TransferRow"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
</Columns>
<EmptyDataTemplate>
<table cellspacing="0" border="1" style="border-collapse: collapse;" width="385px;">
<tr style="color: White; background-color: #3AC0F2;">
<th scope="col" style="width: 30px;">
Id
</th>
<th scope="col" style="width: 150px;">
Name
</th>
<th scope="col" style="width: 150px;">
Country
</th>
</tr>
<tr>
<td colspan="3" align="center">
No Records Available
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
<hr />
<asp:GridView ID="GridView2" HeaderStyle-BackColor="#3AC0F2" AutoGenerateColumns="false"
HeaderStyle-ForeColor="White" runat="server">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="34" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="173" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="173" />
</Columns>
<EmptyDataTemplate>
<table cellspacing="0" border="1" style="border-collapse: collapse;" width="385px;">
<tr style="color: White; background-color: #3AC0F2;">
<th scope="col" style="width: 30px;">
Id
</th>
<th scope="col" style="width: 150px;">
Name
</th>
<th scope="col" style="width: 150px;">
Country
</th>
</tr>
<tr>
<td colspan="3" align="center">
No Records Available
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</div>
</form>
</body>
</html>
C#:
public DataTable Table1
{
get
{
return (DataTable)ViewState["DataTable"];
}
set
{
ViewState["DataTable"] = value;
}
}
public DataTable Table2
{
get
{
return (DataTable)ViewState["DataTable1"];
}
set
{
ViewState["DataTable1"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt2 = new DataTable();
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
Table1 = dt;
dt2 = null;
GridView2.DataSource = dt2;
GridView2.DataBind();
}
}
protected void TransferRow(object sender, EventArgs e)
{
DataTable dt = Table1;
int index = ((sender as ImageButton).NamingContainer as GridViewRow).RowIndex;
DataTable dt2 = new DataTable();
if (Table2 == null)
{
dt2.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
}
else
{
dt2 = Table2;
}
DataRow dr = dt2.NewRow();
dr["Id"] = dt.Rows[index]["Id"];
dr["Name"] = dt.Rows[index]["Name"];
dr["Country"] = dt.Rows[index]["Country"];
dt2.Rows.Add(dr);
Table2 = dt2;
this.GridView2.DataSource = dt2;
this.GridView2.DataBind();
dt.Rows.RemoveAt(index);
dt.AcceptChanges();
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
Table1 = dt;
}
Namespace:
using System.Data;
Image:

Thank You.