Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Reply
How to merge one DataTable to another DataTable in c#?
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Mani Kandan
7y
233
1
Reply
Hello Everyone,
I have two datatable from this query:-
string
sql =
"SELECT * FROM Tble_UserSetUp inner join Tble_Login on Tble_UserSetUp.Id = Tble_Login.UserId WHERE Tble_Login.UserId='"
+ Userid +
"';select count(*) as docCount from Tble_UserSetUp inner join Tble_Documents on Tble_Documents.UserId = Tble_UserSetUp.Id where Tble_Documents.UserId ='"
+ Userid +
"'"
;
DataTable dt =
new
DataTable();
DataTable dt1 =
new
DataTable();
da.Fill(ds);
dt = ds.Tables[0];
dt1 = ds.Tables[1];
dt
is getting all userdetails and
dt1
is getting only count.
How can I merge
dt1
inside
dt
? There is UserSetUp model class
contain int type
countID
, how to assign count value to
countID
variable
from
dt1
?
public
partial
class
UserSetUp
{
public
Int64 countID {
get
;
set
; }
}
var userList = from myRow
in
dt.AsEnumerable()
where myRow.Field<
bool
>(
"IsActive1"
) ==
true
select myRow;
List<Model.UserSetUp> objUserSetUp = userList.Select(m =>
new
Model.UserSetUp()
{
Id = m.Field<Int64>(
"Id"
),
FirstName = m.Field<
string
>(
"FirstName"
),
SurName = m.Field<
string
>(
"SurName"
),
Computer_Name = m.Field<
string
>(
"Computer_Name"
),
IP_Address = m.Field<
string
>(
"IP_Address"
),
LogInTime = m.Field<
string
>(
"LogInTime"
),
UserName = Decrypt(m.Field<
string
>(
"UserName"
)),
Password = Decrypt(m.Field<
string
>(
"Password"
)),
login_Id = m.Field<Int64>(
"login_Id"
),
UserType =
"Documents Scanned"
,
countID = ? /*
How can I assign dt1 value inside this variable?
*/
}).ToList();
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Adding to a string list XMLArrayItem using Get Set
Object reference not set to an instance of an object