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
How may clustered index we can create in table?
Which browsers support the xmlhttprequest object?
Explain the asp.net page life cycle.
How to create a db connection at one place/page so that we can use that connection for all pages/forms/windows.what r the steps ned to be performed if question not clear,let me know
What does occur first in ASP.Net, Authentication or Authorization?
By default, Web API sends HTTP response with which of the following status code for all uncaught exception?
What is round trip in asp.net?
what are the events raised in asp.net page life cycle?in which stage view state can be loaded?
Define what is razor? : asp.net mvc
Let's say I have an existing application written using vb6 and this application utilizes windows 2000 com+ transaction services. How would you approach migrating this application to.net?
What is a global postback url?
How can we secure the data which is send from client side to server? Like the login id and paasword needs to be authenticated on the server but we cannot send it in plain text into the server.One more thing we are not using the SSL here.
What symbol specifies the beginning of a query string?
Is asp.net a language?
How is mvc different from asp.net? : Asp.Net MVC