J
javatopia
I am creating a data grid's columns on the fly in my web page. The Bind
operation works just fine, and data is displayed correctly when I change the
layout of the grid (add/remove columns).
I change the data grid by first removing all of the columns then adding each
of the columns that I need for a particular report.
My data grid has a "sort" handler:
this.Report.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.Report_SortCommand);
which is set in the InitializeComponent() method of my WebForm. I setup the
column data model in my BindData() method of the form, which occurs AFTER the
initialization (of course).
This is my Report_SortCommand:
private void Report_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string expr = e.SortExpression;
string oldexpr = (string)ViewState["DataSortExpression"];
if(oldexpr == expr)
{
ViewState["DataSortExpression"] = expr + " DESC";
}
else
{
ViewState["DataSortExpression"] = expr;
}
BindData(); // -> This creates the re-creates the columns in the
grid
}
So I put a breakpoint in the sort method and click on one of the column
titles. The data grid goes blank and my breakpoint never gets hit.
SOOO - when I remove the columns from a datagrid, does the sort event
delegate get cleared ?? How do I get the sort event to call my custom sort
handler?
Thanks
-- Jake
operation works just fine, and data is displayed correctly when I change the
layout of the grid (add/remove columns).
I change the data grid by first removing all of the columns then adding each
of the columns that I need for a particular report.
My data grid has a "sort" handler:
this.Report.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.Report_SortCommand);
which is set in the InitializeComponent() method of my WebForm. I setup the
column data model in my BindData() method of the form, which occurs AFTER the
initialization (of course).
This is my Report_SortCommand:
private void Report_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string expr = e.SortExpression;
string oldexpr = (string)ViewState["DataSortExpression"];
if(oldexpr == expr)
{
ViewState["DataSortExpression"] = expr + " DESC";
}
else
{
ViewState["DataSortExpression"] = expr;
}
BindData(); // -> This creates the re-creates the columns in the
grid
}
So I put a breakpoint in the sort method and click on one of the column
titles. The data grid goes blank and my breakpoint never gets hit.
SOOO - when I remove the columns from a datagrid, does the sort event
delegate get cleared ?? How do I get the sort event to call my custom sort
handler?
Thanks
-- Jake