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
Explain different types of Caching techniques in ASP.NET?
What are the different session state management options available in asp.net?
How to handle errors in Web API?
What are Caching techniques in .NET
How to find out what version of asp.net I am using on my machine?
Which tool you have done?
What is the difference between server-side scripting and client-side scripting?
Explain the benefits of viewstate?
Explain how do you validate the controls in an asp .net page?
How would you enable impersonation in the web.config file?
What is an il?
What is the concept of postback in asp.net?
Whats the difference between abstract factory pattern and factory pattern?
How can u debug your .net application?
What does a switch do?