Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic columns not sorting in DataGrid

Reply
Thread Tools

Dynamic columns not sorting in DataGrid

 
 
=?Utf-8?B?amF2YXRvcGlh?=
Guest
Posts: n/a
 
      10-01-2004
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.DataGridSortCommandEvent Handler(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.DataGridSortCommandEvent Args 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
database columns vs. gui columns and sorting ittay.dror@gmail.com Java 5 03-04-2006 10:48 AM
Dynamic columns and sorting/paging in DataGrid javatopia ASP .Net Web Controls 0 10-19-2004 05:17 PM
Re: datagrid sorting dynamic columns avnrao ASP .Net 3 06-06-2004 05:59 AM
Dynamic columns in DataGrid, Paging/Sorting and Data Caching Kostia ASP .Net Datagrid Control 0 04-16-2004 10:20 PM
Dynamic Columns Sorting issue in DataGrid Jordo ASP .Net 0 10-31-2003 03:40 PM



Advertisments