apurva

apurva

  • NA
  • 7
  • 0

problem with DataGrid1.AllowSorting = true;

Apr 2 2004 2:18 PM
Hi, I am observing a weird thing here ! I generate my datagrid columns programatically (the columns depend on some conditions) and for that, I have to do something like this : DataGrid1.AutoGenerateColumns = false; DataGrid1.AllowSorting = true; BoundColumn col = new BoundColumn(); col.HeaderText="Date"; col.DataField="insert_date"; col.DataFormatString = "{0:d}"; col.ItemStyle.Wrap = false; col.SortExpression = "Date"; DataGrid1.Columns.Add(col); But, my sorting does not work if the line: DataGrid1.AutoGenerateColumns = false; is present. If I comment out this line of code, then the sorting works - that too for some of the columns and not all. Also, I observed that by having this line in my code, the program execution (most probably) does not even enter the DataGrid1_SortCommand(...) method ! I am lost, if someone can shed some light, it would be great. Waiting, -Apurva.

Answers (7)