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
What are the disadvantages of view state?
Why is asp.net so popular?
What is http only cookie?
How to create discussion forum in asp.net mvc? : Asp.Net MVC
Explain about solution explorer window?
What is difference between session and cookie?
What is view state and how it works in asp net?
Which browsers support the xmlhttprequest object?
Name the two properties are on every validation control?
How to include silver light .xap page into asp.net web application and what is the purpose of using silverlight application?
What is enableviewstate?
In early binding will the method invoked on com component will verify it?s existance in the system or not ?
What is the function used for removing an event listener?
What websites use asp.net?
What is asp net application object?