Search code examples
asp.netajaxgridviewupdatepanel

How do I take a BLOB value from a database and store it in a string in a custom object?


I am getting the following error using an update panel with a gridview.

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

I have looked at all the "fixes" for this and none of them seem to be working. It works just fine on page load but when I click my async button, One row of the grid processes (I can look in the javascript debug) but after the firstrow is processed, I get the above error at this line.

try { _this._webRequest.completed(Sys.EventArgs.Empty); } finally { if (_this._xmlHttpRequest != null) { _this._xmlHttpRequest.onreadystatechange = Function.emptyMethod; _this._xmlHttpRequest = null; } }

Here is my gridview

 <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <table border="0" cellpadding="2" cellspacing="0" width="100%" id="Table3">
            <tr>
                <td width="100%">
                    <table border="0" cellpadding="0" width="100%" id="Table4">
                        <tr>
                            <td>
                                <span style="font-size: x-large;">Results</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left;">
                                <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
                                <asp:Label ID="lblCount" runat="server" ForeColor="Black"></asp:Label>
                            </td>
                            <td style="text-align: right;">
                                <asp:Label ID="lblCount2" runat="server" ForeColor="Black"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:GridView Width="100%" ID="resultsGrid" AutoGenerateColumns="false" runat="server"
                                    AllowPaging="true" AllowSorting="true" PageSize="20" OnPageIndexChanging="gridView_PageIndexChanging"
                                    OnSorting="gridView_Sorting" PagerSettings-Position="TopAndBottom" PagerStyle-HorizontalAlign="Center">
                                    <Columns>
                                        <asp:TemplateField HeaderStyle-Width="2%" ControlStyle-Width="100%">
                                            <ItemTemplate>
                                                <%# Container.DataItemIndex + 1 + "." %>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField Visible="false" SortExpression="record_id">
                                            <ItemTemplate>
                                                <asp:Label ID="lblRecordID" runat="server" Text='<%# Eval("RecordID") %>' Visible="false"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-Width="7%" ControlStyle-Width="100%" HeaderText="Note Type"
                                            SortExpression="business_content_type_cd">
                                            <ItemTemplate>
                                                <asp:Label ID="lblNoteType" runat="server" Text='<%# Eval("NoteType") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-Width="10%" ControlStyle-Width="100%" HeaderText="Author"
                                            SortExpression="author_user_name">
                                            <ItemTemplate>
                                                <asp:Label ID="lblAuthor" runat="server" Text='<%# Eval("Author") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-Width="7%" ControlStyle-Width="100%" HeaderText="Date"
                                            SortExpression="content_dttm">
                                            <ItemTemplate>
                                                <asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-Width="60%" ControlStyle-Width="100%">
                                            <ItemTemplate>
                                                <asp:Label ID="lblData" runat="server" Text='<%# Eval("NoteContent") %>'></asp:Label>
                                                <asp:HyperLink ID="linkMore" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField SortExpression="size" Visible="false">
                                            <ItemTemplate>
                                                <asp:Label ID="lblSize" runat="server" Text='<%# Eval("Size") %>' Visible="false"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left;">
                                <asp:Label ID="lblCount3" runat="server" ForeColor="Black"></asp:Label>
                            </td>
                            <td style="text-align: right;">
                                <asp:Label ID="lblCount4" runat="server" ForeColor="Black"></asp:Label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

I am completely stumped here, any help would be great.

Here is my AJAX Response from FireBug

14008|updatePanel|ctl00_ContentPlaceHolder_UpdatePanel1|
        <table border="0" cellpadding="2" cellspacing="0" width="100%" id="Table3">
            <tr>
                <td width="100%">
                    <table border="0" cellpadding="0" width="100%" id="Table4">
                        <tr>
                            <td>
                                <span style="font-size: x-large;">Results</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left;">
                                <span id="ctl00_ContentPlaceHolder_lblError" style="color:Red;"></span>
                                <span id="ctl00_ContentPlaceHolder_lblCount" style="color:Black;">5 found</span>
                            </td>
                            <td style="text-align: right;">
                                <span id="ctl00_ContentPlaceHolder_lblCount2" style="color:Black;">1 to 5 of 5</span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <div>
<table cellspacing="0" rules="all" border="1" id="ctl00_ContentPlaceHolder_resultsGrid" style="width:100%;border-collapse:collapse;">
    <tr>
        <th scope="col" style="width:2%;">&nbsp;</th><th scope="col" style="width:7%;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder$resultsGrid','Sort$business_content_type_cd')">Note Type</a></th><th scope="col" style="width:10%;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder$resultsGrid','Sort$author_user_name')">Author</a></th><th scope="col" style="width:7%;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder$resultsGrid','Sort$content_dttm')">Date</a></th><th scope="col" style="width:60%;">&nbsp;</th>
    </tr><tr>
        <td>
                                                1.
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl03_lblNoteType" style="display:inline-block;width:100%;">General</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl03_lblAuthor" style="display:inline-block;width:100%;">LISA WHIPKEY</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl03_lblDate" style="display:inline-block;width:100%;">3/17/2011 4:08:15 PM</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl03_lblData" style="display:inline-block;width:100%;">HIS ROAD WAS CONTROLLED BY A STOP SIGN. HE NEEDED TO MAKE A LEFT ON TO PINEAND THEN MAKE A LEFT AGAIN QUIKELY INTO A PARKING LOT TO THE LEFT.         HE LOOKED LEFT AND THE INSURED SAW A CAR THAT WAS COMING AT HIM. HE WAS    WAITING FOR THE CAR TO PASS BUT THE CAR THAT WAS COMING AT HIM TURNED INTO THE PARKING LOT THAT HE NEEDED TO TURN INTO. THE INSURED WAS AT THE STOP   SIGN FOR APPROX 20 TO 30 SECONDS. THE LIGHTS WERE GLARINIG ON THE ROAD.��������������</span>
                                                <a id="ctl00_ContentPlaceHolder_resultsGrid_ctl03_linkMore" style="display:inline-block;width:100%;"></a>
                                            </td>
    </tr><tr>
        <td>
                                                2.
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl04_lblNoteType" style="display:inline-block;width:100%;">General</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl04_lblAuthor" style="display:inline-block;width:100%;">LISA WHIPKEY</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl04_lblDate" style="display:inline-block;width:100%;">3/17/2011 4:07:41 PM</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl04_lblData" style="display:inline-block;width:100%;">CALLED THE INSURED MIKE CHALLEEN AT 406-529-5534 LVM CALLED THE CELL OF    INSD MIIKE CHALLEEN AT 406-529-5534 CONFIRMED R/S FROM THE INSURED.                                                                                   THE INSD DRIVING A FRIENDS VEHICLE.  THE INSD WAS STAYING IN MISSOULA FOR ACOUPLE OF DAYS FOR WORK. HE MET MIKE BROWN FOR DINNER AND INSD MIKE HALLEENJUST PURHCES A NEW 2001 CAMARO SS/SP  VIN - 2G1FT1EW0A9123754, RED IN COLORMIKE BROWN WAS INTERESTED IN PURCHASING ONE AND WANTED TO DRIVE IT FOR THE EVENING. HE AGREED AND SO THE INSURED DROVE MIKE BROWNS VEHICLE WHICH WAS AFORD TRUCK DESIEL 4 DR. TWO TONE PU LONG BED. MIKE BROWN DROVE HIS VEHICLE 2010 CAMARO. SO IN THE MORNING GOING TO WORK AT APPROX 7:30 AM THIS MORNING THE INSURED WORKED OUT AHEAD A SCHEDULE FROM THE HOTEL DECIDED TO GO IN   EARLY.                                                                                                                                                TRAVELING DOWN PATTEE N/B</span>
                                                <a id="ctl00_ContentPlaceHolder_resultsGrid_ctl04_linkMore" href="logNoteDetail.aspx?noteID=0" target="_blank" style="display:inline-block;width:100%;">more</a>
                                            </td>
    </tr><tr>
        <td>
                                                3.
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl05_lblNoteType" style="display:inline-block;width:100%;">General</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl05_lblAuthor" style="display:inline-block;width:100%;">LISA WHIPKEY</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl05_lblDate" style="display:inline-block;width:100%;">3/17/2011 3:58:44 PM</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl05_lblData" style="display:inline-block;width:100%;">GENERAL NOTE TESTING 123456GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG G  G  G  G GG G G G G G G G G G GGGGGGGG G   G  G G  G   G  G  G  G  G G G  G  G G  G GGG G G FGHJH HFDGKL HFG JDFHGKJDHFG DHFG FH KGHDF GHFKJDHGKH DGHFK   HF    STOPPED THE CK FOR 100,000, SCOTT G. IS NOW DEFENDING THE INSD AND NOT PROTECTING US. I ISSUED OUT THE PAYMENT AND THEN HE HAD THE CK. NOW REVERSED   AND WILL NOT RELEASE THE FUNDS TO P/C AND WAS HOLDING FOR AN EXCHANGE OF   PAYMENT.                                                                                                                                              BOHXXX, SIMPXXX AND TRAXXXL PC                                             283 WEST FRONT STREET, SUITE 201                                           MISSOULA, MONTANA 59802 (MISSOULA CO.)                                     PHN:  406-532-7800                                                         HTTP://WWW.BSTLAWFIRM.COM                                                                           </span>
                                                <a id="ctl00_ContentPlaceHolder_resultsGrid_ctl05_linkMore" href="logNoteDetail.aspx?noteID=0" target="_blank" style="display:inline-block;width:100%;">more</a>
                                            </td>
    </tr><tr>
        <td>
                                                4.
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl06_lblNoteType" style="display:inline-block;width:100%;">General</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl06_lblAuthor" style="display:inline-block;width:100%;">LISA WHIPKEY</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl06_lblDate" style="display:inline-block;width:100%;">3/10/2011 3:55:25 PM</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl06_lblData" style="display:inline-block;width:100%;">PLAN OF ACTION                                                             IUY                                                                        UYUY KJHKJ                                                                 HKJH                                                                       LKJHKJLH                                                                   JKHKJH                                                                     JKH                                                                        KJHJ                                                                       KH                                                                         JKH                                                                        LJ                                                                         HJK                                                                        HLJ                                                                        HLHJ                     </span>
                                                <a id="ctl00_ContentPlaceHolder_resultsGrid_ctl06_linkMore" href="logNoteDetail.aspx?noteID=0" target="_blank" style="display:inline-block;width:100%;">more</a>
                                            </td>
    </tr><tr>
        <td>
                                                5.
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl07_lblNoteType" style="display:inline-block;width:100%;">General</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl07_lblAuthor" style="display:inline-block;width:100%;">LISA WHIPKEY</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl07_lblDate" style="display:inline-block;width:100%;">3/10/2011 3:53:57 PM</span>
                                            </td><td>
                                                <span id="ctl00_ContentPlaceHolder_resultsGrid_ctl07_lblData" style="display:inline-block;width:100%;">DFSHK                                                                      HKJH                                                                       KJHK HKJ                                                                   OU OI                                                                      UOIU                                                                       U OU O                                                                     UY                                                                         UY                                                                         Y                                                                          Y                                                                          OIJ                                                                        J                                                                          N                                                                          L                        </span>
                                                <a id="ctl00_ContentPlaceHolder_resultsGrid_ctl07_linkMore" href="logNoteDetail.aspx?noteID=0" target="_blank" style="display:inline-block;width:100%;">more</a>
                                            </td>
    </tr>
</table>

5 found 1 to 5 of 5

What I do in this code is convert a BLOB value from a database and store it in a string in a custom object. What seems to be happening is that there are odd characters being put at the end of the string. Here is what I am doing to convert the data

     byteBLOBData = (Byte[])(row[3]);
                        row["data"] = System.Text.Encoding.UTF8.GetString(byteBLOBData);

Solution

  • One of the best ways to debug these issues is to inspect the AJAX response in Firebug and look for stray markup that doesn't belong. If you update your question with a copy/paste of that AJAX response, I can tell you which part shouldn't be there. Then, you know what to look for in your server-side code.