I have used the following code:
ManageUser userObj = new ManageUser();
List<StoreUserList> storeList = new List<StoreUserList>();
StoreUserList sl = new StoreUserList();
foreach (var items in userObj.GetStoreUserList(Username, Password))
{
sl.UserName = items[0].ToString();
sl.EmailId = items[1].ToString();
sl.FirstName = items[2].ToString();
sl.LastName = items[3].ToString();
sl.BadLoginCount = Convert.ToInt32(items[4]);
sl.ManagerName = items[5].ToString();
storeList.Add(sl);
}
StoreUserList is my Model in which i have defined all the properties.
ManagerUser is the class which will return the data in the form of List<DataRow>.
So, i order to populate the a generic list of my model type i have used the above code, to do it.
But, as you can see i have hard-coded all the values to bind the model and then added that model to the list. I just wanted to know that is there some other way to do it or some magic way to do it in easy?