WPF DataGrid值未更新

时间:2018-09-04 08:35:34

标签: c# wpf

在这里,我尝试更改“ DateCreated”列中所有单元格的日期格式。 My值已正确转换,但未显示在DataGrid上。

我在哪里错了?

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;
    }         
}

0 个答案:

没有答案