Hi try like this...
foreach (DataRow row in dt.Rows)
{
lstData.Add(new Tablelist() { FileName=csv, process = row["process"] + "", Event = row["Event"] + "", status = row["status"] + "" });
}
}
DataTable dtoutput = new DataTable();
var columnNames = lstData.Select(k => k.FileName).Distinct();
foreach (string columnName in columnNames)
dtoutput.Columns.Add(columnName, typeof(string));
DataRow newrowPassCount = dtoutput.NewRow();
foreach (string columnName in columnNames) {
int count = lstData.Where(k=> k.FileName == columnName).Count(k => k.status == "Pass");
newrowPassCount[columnName] = count;
}
dtoutput.Rows.Add(newrowPassCount);
DataRow newrowFailCount = dtoutput.NewRow();
foreach (string columnName in columnNames)
{
int count = lstData.Where(k => k.FileName == columnName).Count(k => k.status == "Fail");
newrowFailCount[columnName] = count;
}
dtoutput.Rows.Add(newrowFailCount);
gridview.datasource = dtoutput;
gridview.databind();
add a new property
FileName
in the class
class Tablelist
{
public string process { get; set; }
public string Event { get; set; }
public string status { get; set; }
public string FileName { get; set; }
}