プログラムでデータソースにデータを入力する必要があります。
SqlDataReaderで結果を取得し、DataTableにSqlDataReaderの結果を入力します。
次に、ケースにコストを含め、必要な出力に一致する列を持つ新しいDataTableを作成します。次に、最初のDataTableの各行を反復処理し、コスト計算を使用して新しいDataTableに行を追加します。
例えば、
DataTable oldTable = new DataTable();
oldTable .Load(rdr); // where rdr is your SqlDataReader
次に、新しいテーブルを作成します
DataTable newTable = new DataTable();
DataColumn noteID = new DataColumn("Cost", typeof(string));
newTable.Columns.Add(noteID);
//Add other columns
foreach (DataRow row in oldTable .Rows)
{
DataRow newRow = newTable.NewRow();
newRow["Cost"] = //your calculation
...
...
newTable.Add(newRow);
}
次に、グリッドのデータソースをNewTableに設定します