Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to merge 2 tables fields in DataTable in asp.net

Answer Posted / ankur sehgal

Consider a dataset(ds) having two datatables or we can say
that it contains data from two tables..

System.Data.DataTable dt = new DataTable();
dt.Columns.Add("Field1", typeof(string));
dt.Columns.Add("Field2", typeof(string));

if(ds.Tables[0].Rows.Count > 0)
{
foreach(DataRow dr in ds.Tables[0].Rows)
{
DrNew = dt.NewRow();
DrNew[0] = dr["Field1"].ToString();
}
}

if(ds.Tables[1].Rows.Count > 0)
{
foreach(DataRow dr in ds.Tables[1].Rows)
{
DrNew = dt.NewRow();
DrNew[0] = dr["Field2"].ToString();
}
}
dt.AcceptChanges();

Is This Answer Correct ?    22 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of view state?

1113


Why is asp.net so popular?

975


What is http only cookie?

1115


How to create discussion forum in asp.net mvc? : Asp.Net MVC

1051


Explain about solution explorer window?

1042


What is difference between session and cookie?

1010


What is view state and how it works in asp net?

992


Which browsers support the xmlhttprequest object?

1034


Name the two properties are on every validation control?

999


How to include silver light .xap page into asp.net web application and what is the purpose of using silverlight application?

2709


What is enableviewstate?

978


In early binding will the method invoked on com component will verify it?s existance in the system or not ?

2641


What is the function used for removing an event listener?

1027


What websites use asp.net?

1032


What is asp net application object?

1023