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 different methods of session maintenance in asp.net?
What are the new data controls in asp.net 2.0?
What is the application pool?
Is asp.net a programming language?
Write a code for passing ArrayList in Web API?
What is asp.net version?
Is asp.net different from asp? If yes, explain how?
Where do we store our connection string in asp.net application?
What is asp.net master page?
8. Why do you want to work here?
What is a web based system?
How do you hide the columns?
How you can access the values from the Repeater control in ASP.NET?
Define data caching?
How should I destroy my objects in asp.net?