Populating a SelectList from a DataTable

前端 未结 8 1114
说谎
说谎 2020-12-18 11:12

I ran a query and returned a datatable,

myDataAdapter.Fill(myDataTable);

Now what is the best way to load the row values \"Value\" and \"Te

8条回答
  •  渐次进展
    2020-12-18 11:40

    Looks fine. I would make it a bit cleaner by creating a constructor for MyTestObj that accepted a DataRow. That would allow you to write:

    MyList.Add(new MyTestObj(mydataRow));
    

提交回复
热议问题