TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kwasi Denkyira
1.2k
197
15.1k
Adding sorted list to DataTable Row
Nov 2 2019 4:25 PM
I am trying to add IEnumerable items of string to a datatable row, but can't get it sorted. I want to get an output of
james,john
Mary,Ann
Edward,Anthony
but I am getting james,johnMary,AnnEdward,Anthony
Below is my code. Any help will be appreciated.
private
void
addToDataTable<T>(IEnumerable<T> rDataRow,
string
dataRowType)
{
try
{
foreach
(var r
in
rDataRow)
{
var type = r.GetType();
DataRow dr = reportData.NewRow();
var ListItems =
""
;
if
(type.GetProperty(
"admin"
) !=
null
)
{
foreach
(var t
in
(IEnumerable)type.GetProperty(
"admin"
).GetValue(r,
null
))
{
ListItems += t;
}
dr.SetField(dcAdmin, ListItems);
}
reportData.Rows.Add(dr);
}
}
}
Reply
Answers (
2
)
Need string if har row to show value, else to be ----
object Reference Not set to and Intense of an Object in mv5