B
bfwd
I have the following in VS 2008. I get a stack overflow condition
raised when it tries to execute the
"GridView1.Sort(expression, direction)" statement in the
GridView1_Sorting event handler. Is there recursion going on here that
I do not see?
-------------------------------------------------------------------------------------------------------------------------------------------------
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
AutoGenerateSelectButton="True" BackColor="White"
BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical"
onsorting="Gridview1_Sorting"
OnSorted="Gridview1_sorted"
onselectedindexchanged="GridView1_SelectedIndexChanged"
onrowediting="GridView1_RowEditing" >
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
sqlcmd = New SqlCommand("select * from
dbo.semestertable", myDB)
myDB.Open()
reader = sqlcmd.ExecuteReader
GridView1.DataSource = reader
GridView1.DataBind()
myDB.Close()
End If
End Sub
Sub GridView1_Sorting(ByVal sender As Object, ByVal e As
GridViewSortEventArgs)
Dim expression As String
Dim direction As SortDirection
expression = e.SortExpression
If e.SortDirection = SortDirection.Ascending Then
direction = SortDirection.Descending
Else
direction = SortDirection.Ascending
End If
GridView1.Sort(expression, direction)
End Sub
Sub GridView1_Sorted(ByVal sender As Object, ByVal e As
EventArgs)
message.text = "you sorted on column: " &
GridView1.SortExpression & _
" in " & GridView1.SortDirection & " order"
message.visible = True
End Sub
--------------------------------------------------------------------------------------------------------------------------------
raised when it tries to execute the
"GridView1.Sort(expression, direction)" statement in the
GridView1_Sorting event handler. Is there recursion going on here that
I do not see?
-------------------------------------------------------------------------------------------------------------------------------------------------
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
AutoGenerateSelectButton="True" BackColor="White"
BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical"
onsorting="Gridview1_Sorting"
OnSorted="Gridview1_sorted"
onselectedindexchanged="GridView1_SelectedIndexChanged"
onrowediting="GridView1_RowEditing" >
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
sqlcmd = New SqlCommand("select * from
dbo.semestertable", myDB)
myDB.Open()
reader = sqlcmd.ExecuteReader
GridView1.DataSource = reader
GridView1.DataBind()
myDB.Close()
End If
End Sub
Sub GridView1_Sorting(ByVal sender As Object, ByVal e As
GridViewSortEventArgs)
Dim expression As String
Dim direction As SortDirection
expression = e.SortExpression
If e.SortDirection = SortDirection.Ascending Then
direction = SortDirection.Descending
Else
direction = SortDirection.Ascending
End If
GridView1.Sort(expression, direction)
End Sub
Sub GridView1_Sorted(ByVal sender As Object, ByVal e As
EventArgs)
message.text = "you sorted on column: " &
GridView1.SortExpression & _
" in " & GridView1.SortDirection & " order"
message.visible = True
End Sub
--------------------------------------------------------------------------------------------------------------------------------