문제

I am trying to use an update panel within an InsertItemTemplate of a Formview. When "Other" is selected from one DropDownlist, another Dropdownlist is hidden. When I remove the update panel this works fine, the record is created no problem. However when the DropDownList is inside an UpdatePanel, I get the following error on inserting :

Oracle.DataAccess.Client.OracleException: ORA-01008: not all variables bound.

I haven't included all of the ASP.NET and code behind, please ask if you'd like to see anything else, there are more bound fields and alot of data validation. Here is part of the ASP.NET:

<asp:Formview 

        ID="fvJobs"
        DataSourceID="fvSqlDataSource"
        DataKeyNames="JOB_ID"
        DefaultMode="Edit"
        OnItemInserting="fvJobs_FileUpl"
        OnItemInserted="fvJobs_ItemInserted"
        OnItemupdating="fvJobs_FileUp2"
        OnItemUpdated="fvJobs_ItemUpdated"
         runat="server">


 <asp:DropDownList ID="InsertLocList" 
                                         SelectedValue='<%# Bind("JOB_LOCATION") %>' 
                                         Autopostback="true"
                                         CssClass="ddl"
                                         OnSelectedIndexChanged="InsertLocList_IndexChanged"
                                         RunAt="Server" >
                                         <asp:ListItem Text="--Select One--" Value="-1" />
                                         <asp:ListItem Text="California" Value="CA" />
                                         <asp:ListItem Text="New York" Value="NY" />
                                         <asp:ListItem Text="Pennsylvania" Value="PA" />
                                         <asp:ListItem Text="Texas" Value="TX" />
                                         <asp:ListItem Text="Other" Value="O" />
                                         </asp:DropDownList></label>


                    <asp:UpdatePanel ID="UpdatePanel1" 
                 UpdateMode="Conditional"
                 runat="server">
                 <Triggers>
                   <asp:AsyncPostBackTrigger ControlID="InsertLocList" />
                 </Triggers>
                     <contentTemplate>

                     <span><asp:label id="InsertCatLbl" runat="server"><b>Subsidiary:</b></asp:label></span>

                        <asp:DropDownList ID="InsertCatList" 

                                         SelectedValue='<%# Bind("JOB_CATEGORY") %>' 
                                         CssClass="ddl"
                                         RunAt="Server" >
                           <asp:ListItem Text="--Select One--" Value="-1" />

                                         <asp:ListItem Text="SRC" Value="SRC" />
                                         <asp:ListItem Text="FRN" Value="FRN" />
                                         <asp:ListItem Text="SUPDIST" Value="SUPDIST" />
                                         <asp:ListItem Text="Stream" Value="STREAM" />

                                         </asp:DropDownList>
                                         </contentTemplate>
                                         </asp:UpdatePanel>

Here is some of the code behind:

Protected Sub InsertLocList_IndexChanged(sender As Object, e As EventArgs)



Dim ddlLoc As DropDownList = _
      CType(fvJobs.FindControl("InsertLocList"), DropDownList)

Dim ddlCat As DropDownList = _
      CType(fvJobs.FindControl("InsertCatList"), DropDownList)

      Dim catLbl As Label = _
      CType(fvJobs.FindControl("InsertCatlbl"), Label)


      If ddlLoc.SelectedValue = "O"

      ddlCat.selectedvalue="SRC"
        ddlCat.visible=false
        catLbl.visible=false



    else

    ddlCat.visible = true
    catLbl.visible = true

    end if



end sub

The strange thing is this works perfectly if I remove the UpdatePanel. I can't figure out why the Bind inside the Update Panel doesn't seem to be working. I've phrased the google searches every way I can think of and I can't seem to find anyone with a similar problem, any help would be greatly appreciated, thanks.

UPDATE Here is the SqlDataSource for the formview:

<asp:SqlDataSource ID="fvSqlDataSource" 
          ConnectionString="<%$ ConnectionStrings:Oracle %>" 
          ProviderName="<%$ ConnectionStrings:Oracle.ProviderName %>" 
          SelectCommand="SELECT JOB_DESC, JOB_ID, JOB_CATEGORY, JOB_LOCATION, JOB_DATE_BEGIN, JOB_DATE_CLOSED, JOB_FILENAME, JOB_SHOW_INDIC from JOB_POSTING WHERE JOB_ID = :JOB_ID"
          RunAt="server"
          UpdateCommand="UPDATE JOB_POSTING SET JOB_DESC=:JOB_DESC, JOB_LOCATION=:JOB_LOCATION, JOB_CATEGORY=:JOB_CATEGORY, JOB_DATE_BEGIN=TO_DATE(:JOB_DATE_BEGIN, 'MM/DD/YYYY'), JOB_DATE_CLOSED=TO_DATE(:JOB_DATE_CLOSED, 'MM/DD/YYYY'), JOB_FILENAME=:JOB_FILENAME,JOB_SHOW_INDIC=:JOB_SHOW_INDIC WHERE JOB_ID=:JOB_ID"

          InsertCommand="INSERT INTO JOB_POSTING(JOB_DESC, JOB_ID, JOB_LOCATION, JOB_CATEGORY, JOB_DATE_BEGIN, JOB_DATE_CLOSED, JOB_FILENAME, JOB_SHOW_INDIC) 
          VALUES 
         (:JOB_DESC, :JOB_ID, :JOB_LOCATION, :JOB_CATEGORY, TO_DATE(:JOB_DATE_BEGIN, 'MM/DD/YYYY'), TO_DATE(:JOB_DATE_CLOSED, 'MM/DD/YYYY'), :JOB_FILENAME, :JOB_SHOW_INDIC)"
            >

            <SelectParameters>
            <asp:Parameter Name="JOB_ID" Type="String" DefaultValue="0" />
            </SelectParameters>

         <UpdateParameters>
         <asp:parameter Name="JOB_ID" Type="String" DefaultValue="0"/>
         </UpdateParameters>


</asp:SqlDataSource>
도움이 되었습니까?

해결책

I finally got this working. After some more digging I discovered this is a known bug when nesting an UpdatePanel within a Formview's EditItemTemplate or InsertItemTemplate. There are two ways to work around this, I used a ControlParameter to bind the DropDownList in the SqlDataSource:

  <InsertParameters>
     <asp:Parameter Name="JOB_DESC" />
     <asp:Parameter Name="JOB_ID" />     
     <asp:Parameter Name="JOB_FILENAME"  />
     <asp:Parameter Name="JOB_SHOW_INDIC" />
     <asp:Parameter Name="JOB_LOCATION" />
     <asp:ControlParameter ControlID="fvJobs$InsertCatList" Name="JOB_CATEGORY" />
      <asp:Parameter Name="JOB_DATE_BEGIN" />
     <asp:Parameter Name="JOB_DATE_CLOSED" />
     </InsertParameters>

Use ControlParameters for any controls inside the UpdatePanel.

Another work around is to bind the data on Inserting/Updating in the code behind:

Protected Sub RoleSQLDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles
RoleSQLDataSource.Updating

    e.Command.Parameters("@street_name").Value = street_nameTextBox.Text
    e.Command.Parameters("@street_type").Value = street_typeTextBox.Text
    e.Command.Parameters("@street_dir").Value = street_dirTextBox.Text
    e.Command.Parameters("@street_number").Value = street_numberTextBox.Text
    e.Command.Parameters("@street_apt").Value = street_aptTextBox.Text
    e.Command.Parameters("@city").Value = cityTextBox.Text
    e.Command.Parameters("@state").Value = stateTextBox.Text
    e.Command.Parameters("@zip").Value = zipTextBox.Text
    e.Command.Parameters("@district_id").Value = DistrictDropDownList.SelectedValue
End Sub.

Here are links to the resources I used:

http://forums.asp.net/t/1055525.aspx

http://connect.microsoft.com/VisualStudio/feedback/details/292398/formview-and-updatepanel-binding-behavior

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top