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 is a web server? What are the load limits in it?
Where is the view state data stored?
How can u debug your .net application?
How you will manage the state of ASP.NET controls?
Why is an object pool required?
What are the server controls in asp.net?
What are the page life cycle events?
In which situation can you not use a viewstate?
What is a gridview in asp.net?
What is asp.net and how it works?
What does asp stand for in asp.net?
What is the difference between GridView and Repeater controls in ASP.NET?
What is the difference between executescalar and executenonquery?
What is voluum?
Explain About duration in caching technique