简体   繁体   中英

I want to get A field Values let say (Name) From Data Table in C# Mvc,

Here is My Code Please Have a Look. I want to get a Particular Field Values let say Name How can i get it? The method i used is not working

//DataTable result = new DataTable();
//Use Csv Reader to Read Data
using (CsvReader read = new CsvReader(new StreamReader(stream), true))
{
    //Load Data into Data tables
    result.Load(read);                           
}
foreach (DataRow r in result.Rows)
{
    string name = r[1].ToString();
}

I suppose you can directly use DataRow["Name"] .

https://msdn.microsoft.com/en-us/library/system.data.datarow(v=vs.110).aspx

Here is an example:

foreach (DataRow r in result.Rows)
{
    string row_name = r["Name"].ToString();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM