system.stackoverflowexception when using rowdatabound on gridview

184 views Asked by At

Not sure if I'm asking the right question here or if I'm providing enough information as debug in VS isn't giving me any help!

When I run my asp.net webform page with a gridview it is causing a system.stackoverflowexception.

This GV has onPreRender and onRowDataBound event listeners and I found that this error went away when I removed the onRowDataBound.

(Cutting the story short) I found that a single line was causing the issue:

e.Row.Cells[3].Text = "<i aria-hidden=true class=\"glyphicon glyphicon-unchecked text-danger\">";

Now I have no idea why this would cause this exception.

The code in situ:

protected void Gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //SPR / Debrief
            if (e.Row.Cells[3].Text.Equals("True"))
            {
                e.Row.Cells[3].Text = "<i aria-hidden=true class=\"glyphicon glyphicon-check text-success\">";
                if (e.Row.Cells[4].Text.Equals("True"))
                {
                    e.Row.Cells[4].Text = "<i aria-hidden=true class=\"glyphicon glyphicon-flag text-danger\">";
                }
                else
                {
                    e.Row.Cells[4].Text = "";
                }
            }
            else
            {
                e.Row.Cells[3].Text = "<i aria-hidden=true class=\"glyphicon glyphicon-unchecked text-danger\">"; //THIS IS THE LINE OF INTEREST!
                e.Row.Cells[4].Text = "";
            }
        }
    }

Called by

<asp:GridView CssClass="table" ID="GvPlacementReport" runat="server" OnPreRender="GvPlacementReport_PreRender" OnRowDataBound="Gv_RowDataBound" AutoGenerateColumns="false">
            </asp:GridView>

I am also using datatables.net (this is amazing!) and bootstrap (also amazing!) on the page.

If you need more code let me know - sorry I've never had something like this before!

0

There are 0 answers