Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamic columns and sorting/paging in DataGrid

Reply
Thread Tools

Dynamic columns and sorting/paging in DataGrid

 
 
javatopia
Guest
Posts: n/a
 
      10-19-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
dynamic columns and datagrid items SMai24@gmail.com ASP .Net 3 06-28-2006 03:30 PM
dynamic columns and datagrid items SMai24@gmail.com ASP .Net 0 06-28-2006 01:22 PM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
Binded Datagrid Formatting columns or hiding columns ton ASP .Net Web Controls 2 02-11-2004 04:09 AM
Columns and Inherited Datagrid...Active Schema does not support columns rob thomson ASP .Net Datagrid Control 0 09-04-2003 03:09 PM



Advertisments