DataGrid Sorting problem

P

Peter O'Reilly

The DataGridSortCommandEventHandler event will *not* fire unless I *also*
bind data to the datagrid event in the page load event.
Very strange!!!

Needless to say making two trips to the database to perform a sort is very
inefficient. I've used sorting for other datagrids in other projects and
this databinding, take 2 was never necessary.


private void Page_Load(object sender, System.EventArgs e)
{
// if(!Page.IsPostBack) -- must be commented out for SortRequest event
to fire
PopulateGrid(txtSortByColumn.Value);
}

private void dataGrid_SortRequest(object sender,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
this.PopulateGrid(e.SortExpression);
}

private void InitializeComponent()
{

this.Load += new System.EventHandler(this.Page_Load);
this.dataGrid.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dataGrid_Sort
Request);
}
 
P

Peter O'Reilly

The reason is because I have EnableViewState set to false.
Solution: roll my own sorting request postback scheme.

Wishing this consideration was (better) documented.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top