Adonis Izaguirre
Adonis Izaguirre

Reputation: 3

Get data from List<String> column

I have a datatable with the following columns:

DataTable dt = new DataTable();  
dt.Columns.Add("name",typeof(string));  
dt.Columns.Add("Database",typeof(List<String>)); 
dt.Columns.Add("schedule", typeof(String));  
dt.Columns.Add("Path",typeof(List<String>)); 
gridTask.DataSource = dt;

When I insert a new row, everything is ok:

List<string> database = new List<string>(){"test1","test2","test3"};
List<string> path = new List<string>(){"test1","test2","test3"};
dt.Row.add((new object[] {"Test",database,"Test",path });
gridTask.DataSource = dt;

But I want to know how can I get the data from the columns List<String>

Upvotes: 0

Views: 118

Answers (1)

Ravi
Ravi

Reputation: 1172

Try this

List<String> str = (List<String>)dt.Rows[x]["column"];

Upvotes: 2

Related Questions