How can I convert DataTable.Rows
collection to List<Category>
?
I want to set the value of list of values of Data Row in to the List of values of C# object as I mentioned in the below code. kindly advice.
UserData objUserData = null;
DataTable dtUserData = DataAccess.getUserDataTable();
if(dtUserData.Rows.Count>0)
{
foreach(DataRow dr in dtUserData.Rows)
{
objUSerData = new UserData();
List<objUSerData.Category> = Convert.ToString(List<dr["category"]>);
}
}
Here is the Category
class:
[DataContract]
public class category { get; set; }
{
public string category_id {get; set;}
public string category_name {get; set;}
}