By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,492 Members | 3,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,492 IT Pros & Developers. It's quick & easy.

grid view sorting problem

P: n/a
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

Jun 7 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 7, 3:40 pm, bbdobuddy <bbdobu...@discussions.microsoft.com>
wrote:
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?

Jun 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.