Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

A JSON error occurs when AjaxFileUpload is used in a master GridView / detailed FormView #50

@DeanMc67

Description

@DeanMc67

I have a GridView with an SQLdatasource, and a FormView with an SQLdatasource. On selection from the GridView the FormView displays the correct details. - All simple stuff.

If I then put an AjaxFileUpload control in the FormView, I get the following error when I click the upload button:

0x800a139e - JavaScript runtime error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.

Parameter name: data

How do I use an AjaxFileUpload in a detail Formview?

Here is a simple page to show the issue:

  <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ContactID" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="ContactID" HeaderText="ContactID" InsertVisible="False" ReadOnly="True" SortExpression="ContactID" />
            <asp:BoundField DataField="FullName" HeaderText="FullName" ReadOnly="True" SortExpression="FullName" />
        </Columns>
    </asp:GridView>

    <hr />

    <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2" DefaultMode="Edit">
        <EditItemTemplate>
            <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="AjaxFileUpload1_UploadComplete" />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>' />
            <br />
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' />
             <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>

    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TheConnectionString %>" SelectCommand="SELECT [ContactID], [FullName] FROM [Contacts]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TheConnectionString %>" SelectCommand="SELECT [FirstName], [LastName] FROM [Contacts] WHERE ([ContactID] = @ContactID)">
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="ContactID" PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource> 

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions