using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
DataSet ds;
DataTable dt1,dt2;
DataRow r;
DataColumn c1, c2, c3, c4, c5, c6;
protected void Page_Load(object sender, EventArgs e)
{
ds = new DataSet("D-base");
dt1 = new DataTable();
dt2 = new DataTable();
c1 = new DataColumn("empno");
c2 = new DataColumn("empname");
c3 = new DataColumn("depno");
c4 = new DataColumn("depno");
c5 = new DataColumn("depname");
c6 = new DataColumn("depaddress");
dt1.TableName = "emp";
dt2.TableName = "dept";
dt1.Columns.Add(c1); dt1.Columns.Add(c2); dt1.Columns.Add(c3);
dt2.Columns.Add(c4); dt2.Columns.Add(c5); dt2.Columns.Add(c6);
}
protected void Showdt_btn_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
r = dt1.NewRow();
r[c1] = i;
r[c2] = "ramu" + i;
r[c3] = 100 + i;
dt1.Rows.Add(r);
}
ds.Tables.Add(dt1);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
GridView1.Visible = true;
for (int i = 0; i < 10; i++)
{
r = dt2.NewRow();
r[c4] = 100 + i;
r[c5] = "IT deptno " + i;
r[c6] = "Hyd cir no" + i;
dt2.Rows.Add(r);
}
ds.Tables.Add(dt2);
GridView2.DataSource = ds.Tables[1].DefaultView;
GridView2.DataBind();
GridView1.Visible = true;
dt1.Merge(dt2, false, MissingSchemaAction.AddWithKey);
GridView3.DataSource = ds.Tables[0].DefaultView;
GridView3.DataBind();
GridView3.Visible = true;
}
in the Out put it is not getting correct format
there are blank values in between i want them to be correct
any solution?
empno empname depno depname depaddress
0 ramu0 100
1 ramu1 101
2 ramu2 102
3 ramu3 103
4 ramu4 104
5 ramu5 105
6 ramu6 106
7 ramu7 107
8 ramu8 108
9 ramu9 109
100 IT deptno 0 Hyd cir no0
101 IT deptno 1 Hyd cir no1
102 IT deptno 2 Hyd cir no2
103 IT deptno 3 Hyd cir no3
104 IT deptno 4 Hyd cir no4
105 IT deptno 5 Hyd cir no5
106 IT deptno 6 Hyd cir no6
107 IT deptno 7 Hyd cir no7
108 IT deptno 8 Hyd cir no8
109 IT deptno 9 Hyd cir no9
here in this output i want to eliminate blank values and want to merge values below into blank spaces please tell me how ? it is possible to make out put likle hits
empno empname depno depname depaddress
0 ramu0 100 IT deptno 0 Hyd cir no0
1 ramu1 101 IT deptno 1 Hyd cir no1
2 ramu2 102 IT deptno 2 Hyd cir no2
3 ramu3 103 IT deptno 3 Hyd cir no3
4 ramu4 104 IT deptno 4 Hyd cir no4
5 ramu5 105 IT deptno 5 Hyd cir no5
6 ramu6 106 IT deptno 6 Hyd cir no6
7 ramu7 107 IT deptno 7 Hyd cir no7
8 ramu8 108 IT deptno 8 Hyd cir no8
9 ramu9 109 IT deptno 9 Hyd cir no9