Note that there are some explanatory texts on larger screens.

plurals
  1. POSum the values of a WPF datagrid column without additional query?
    text
    copied!<p>I'm populating the following WPF datagrid:</p> <p><img src="https://i.stack.imgur.com/AFN1T.png" alt="enter image description here"></p> <p>Using the following method:</p> <pre><code>private void ButtonFilterWorkflowWhenClick(object sender, RoutedEventArgs e) { var db = new DatabaseHandle(); dataGridWorkflow.ItemsSource = db.DisplayHealthIndicator(DateTime.Now, DateTime.Now); labelWorkflowLastLoaded.Content = "Last Loaded at " + DateTime.Now.ToString(CultureInfo.InvariantCulture) + " with " + dataGridWorkflow.Items.Count.ToString(CultureInfo.InvariantCulture) + " total events."; } </code></pre> <p>Which references the following class object:</p> <pre><code>public DataView DisplayHealthIndicator(DateTime startDate, DateTime endDate) { string queryString = "[marlin].[support_retrieve_workflow_history]"; using (SqlConnection connection = new SqlConnection(GetConnectionString())) { using (var cmd = new SqlCommand(queryString, connection)) { connection.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("date_from", startDate.Date); cmd.Parameters.AddWithValue("date_to", endDate.Date); var reader = cmd.ExecuteReader(); var dt = new DataTable(); dt.Load(reader); connection.Close(); return dt.DefaultView; } } } </code></pre> <p>I'm trying to find a way that I can find the sum of the total column so I can add it to my label but having no success. I can do this with a second query but I'd like to avoid that wherever possible. How should I approach this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload