grid view sorting problem

G

Guest

I have a grid view that pulls data from a dbf file. I set the Allow Sorting
to true and I put my code in the Sorting event.

The problem is that I can't get the sorting to work so I wrote some info to
a text file to see what is happening. What I found out is that when I
clicked on a column to sort it the Sorting function was continuously being
called thus causing the Default Application Pool in IIS to stop.

Here is the code I am using

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
try
{
using (StreamWriter sw = new
StreamWriter("c:\\agserror\\mapMaker.log", true))
{
// Add some text to the file.
sw.WriteLine(DateTime.Now + " : " + e.SortExpression);
sw.WriteLine(DateTime.Now + " : " + e.SortDirection);
}
if (e.SortDirection == SortDirection.Ascending)
{
e.SortDirection = SortDirection.Descending;
}
else
{
e.SortDirection = SortDirection.Ascending;
}
GridView1.Sort(e.SortExpression, e.SortDirection);
GridView1.DataBind();
}
catch (Exception x)
{
using (StreamWriter sw = new
StreamWriter("c:\\agserror\\mapMaker.log", true))
{
// Add some text to the file.
sw.WriteLine(DateTime.Now + " : " + x.Message);
sw.WriteLine(x.StackTrace);
}
}
}

Any help would be appreciated
 
C

cjard

I have a grid view that pulls data from a dbf file. I set the Allow Sorting
to true and I put my code in the Sorting event.

The problem is that I can't get the sorting to work so I wrote some info to
a text file to see what is happening. What I found out is that when I
clicked on a column to sort it the Sorting function was continuously being
called thus causing the Default Application Pool in IIS to stop.

Here is the code I am using

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
....
GridView1.Sort(e.SortExpression, e.SortDirection);


Hmm.. in the "Sorting" event, which fires before a grid is to be
sorted, you tell the grid to sort itself?

Dont you see that as something like calling Button1.PerformClick()
inside the Click() event of Button1?
 

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

Top