this code not showing any output
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;
/* for 2 table display their must be relation bt table
one table contain pk & should contain fk. that not present in tables
so we did it by specify Relation*/
public partial class dataset__with_two_tables : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connectionstring = WebConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString;
SqlConnection con = new SqlConnection(connectionstring);
DataSet ds = new DataSet();
ds.Tables.Add("HumanResources.Employee");
ds.Tables.Add("HumanResources.EmployeeAddress");
ds.Tables["HumanResources.Employee"].Columns.Add("EmployeeID");
ds.Tables["HumanResources.Employee"].Columns.Add("Title");
ds.Tables["HumanResources.EmployeeAddress"].Columns.Add("EmployeeID");
ds.Tables["HumanResources.EmployeeAddress"].Columns.Add("ModifiedDate");
DataRelation dr = new DataRelation("show", ds.Tables["HumanResources.Employee"].Columns["EmployeeID"], ds.Tables["HumanResources.EmployeeAddress"].Columns["EmployeeID"], false);
//ds.Tables["HumanResources.Employee"].ParentRelations.Add(dr);
ds.Relations.Add(dr);
//Retrieving Data from the Relationship
foreach (DataRow row1 in ds.Tables["HumanResources.Employee"].Rows)
{
Response.Write("customertitle:" + row1["Title"].ToString());
foreach (DataRow row2 in row1.GetChildRows(dr))
{
Response.Write("customer add" + row2["ModifiedDate"].ToString());
}
}
GridView4.DataSource = ds.Tables["HumanResources.Employee"];
//Datagrid1.DataSource= ds.DefaultViewManager;
} GridView4.DataBind();
}
}