0

Here I am trying to change the date format of all the cells in 'DateCreated' Column. My The value gets converted correctly but doesn't get displayed on my DataGrid.

Where am i going wrong here?

public static void refreshTicketData(DataTable dt1, DataGrid TicketDG)
{

    using (Global.cmd = new SqlCommand("Select INDEX_Tickets, Status, DateCreated,DateClosed from Tickets WHERE Customer_ID ='" + Global.CustomerID + "'", Global.cs))
    {
        dt1 = new DataTable();
        dt1.Load(Global.cmd.ExecuteReader());


        int count = 0;
        foreach (DataRow row in dt1.Rows)
        {
            string getCurrent = row["DateCreated"].ToString();
            DateTime readDate = DateTime.Parse(getCurrent);
            string finalDate = readDate.ToString("dd-MM-yyyy");


            dt1.Rows[count]["DateCreated"]=finalDate;
            count++;             
        }
        TicketDG.ItemsSource = dt1.DefaultView;
    }         
}
Mrparkin
  • 65
  • 10
  • Try adding TicketDG.Items.Refresh(); after Itemsource update – Justin CI Sep 04 '18 at 09:44
  • Nah that didn't update the UI. I've Been looking at how to use the INotifyPropertyChanged. Looks complicated but worth it in the long run. Anyone got any good studying resources for this? – Mrparkin Sep 04 '18 at 09:50
  • You can have a look at https://stackoverflow.com/questions/7059070/why-does-the-datagrid-not-update-when-the-itemssource-is-changed – Justin CI Sep 04 '18 at 09:58
  • What do you actually see on the screen? And how is your TickerDG defined in your XAML? – mm8 Sep 04 '18 at 13:50

0 Answers0