Sort web Datagrid

  • Thread starter Thread starter Jim McGivney
  • Start date Start date
J

Jim McGivney

I am trying to sort a web datagrid asp.net.
In the sort command I use:

private void MyGrid_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
DataView SortView = anteSet11.Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();
}

In the page_load I use:

private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(anteSet11);
if (!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}

When I press the header, the computer clicks (makes a
sound) but the column does not sort.
I have allowed sorting on the grid's property page.
Generate-columns-automatically is off. The sort command
for each column is appropriate.
The datagrid works in other tasks such as paging, update,
edit and delete.
Any suggestions would be welcomed.
Thanks,
Jim
 
Did you notice that my code was in C#, the example sited
is in vb.net. Any suggestions in C# would be appreciated.
Thanks,
Jim
 
Hi Jim,

Based on my research and experience, the following articles are useful to
you. Please refer to them carefully.

Effective Sorting in ASP .NET DataGrids
http://msdn.microsoft.com/msdnnews/2001/sept/Sorting/Sorting.asp

Adding Sorting to a DataGrid Control
http://authors.aspalliance.com/aspxtreme/webforms/controls/addingsortingtoda
tagrid.aspx

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I have reviewed and used the two articles you have
suggested along with Duthie's book "ASP.net with visual
C#"
Still, when I click a column header, the computer
responds with a clicking noise, the page is reloaded on
the browser, but the column remains unsorted.
The SQL database I am using was upsized from Access2000.
Does this have an effect on the lack of sorting behavior ?
The other possible problem may be in my page_load event
handler.
The code I use is
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(anteSet11);
if (!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
MyGrid.DataBind();
}
}

Any suggestions to my problem along with sample code
would be appreciated.
Thanks in advance for your help,
Jim
 
Hi Jim,

Have you checked Jeff's response to this issue? Does it answer your
question?

If you need further assistance, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Dear Jacob:
I am starting to feel a little dense here.
In your latest reply you mention Jeff's response.
Where is Jeff's response ? It doesn't seem to be in this
thread.
As I mentioned previously, the SQL database I formed by
upsizing a Microsoft Access2000 database will not sort.
When I substitute the sample PUBS database the grid will
sort. Is there a way to allow my database to sort on a
web datagrid ?
Thanks,
Jim
 
Hi James,

It seems that there is some problem in the internet. The followiing is
Jeff's response to this issue.

========================
From: Jeff Louie <[email protected]>
Subject: Re: Sort web datagrid
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: Mon, 01 Dec 2003 19:50:50 -0800

Jim... This may help.

http://www.geocities.com/jeff_louie/net_sort.htm
Sorting a View

Regards,
Jeff


============================

You have not replied this thread for two business days so I want to know if
the problem is resolved. Thank you for your understanding.

In addition, based on my research and experience, a SQL database upsized
from Access2000 should not cause such a problem.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top