Please include the line number of the error next time... as that helps.
It seems that you're assigning a string to the DataType property of DataColumn, which expects a Type object. So the fix would be...
dw.Table.Columns["RequiredDate"].DataType = NewDate.GetType(); // or typeof(DateTime)
Update (for problem#2 - sort doesn't happen)
Adapted from the code snippet from this MSDN Page (look here for implementation of the helper methods).
Formatting of the DataColumn should be the responsibility of the presentation layer/consumer. However if you really need to do this in the DataView - link
private static void DemonstrateDataView(){
// Create one DataTable with one column.
DataTable myTable = new DataTable("myTable");
DataColumn colItem = new DataColumn("item",typeof(DateTime));
myTable.Columns.Add(colItem);
// Add five items.
DataRow NewRow;
for(int i = 0; i <5; i++){
NewRow = myTable.NewRow();
NewRow["item"] = DateTime.Now.AddDays(-i);
myTable.Rows.Add(NewRow);
}
myTable.AcceptChanges();
// Print current table values.
PrintTableOrView(myTable,"Current Values in Table");
DataView secondView = new DataView(myTable);
secondView.Sort = "item";
PrintTableOrView(secondView, "Second DataView: ");
}
Output:
Current Values in Table
8/10/2010 11:34:28 AM
8/9/2010 11:34:28 AM
8/8/2010 11:34:28 AM
8/7/2010 11:34:28 AM
8/6/2010 11:34:28 AM
Second DataView:
8/6/2010 11:34:28 AM
8/7/2010 11:34:28 AM
8/8/2010 11:34:28 AM
8/9/2010 11:34:28 AM
8/10/2010 11:34:28 AM