我正在尝试在 Formview 的 InsertItemTemplate 中使用更新面板。当从一个 DropDownlist 中选择“Other”时,另一个 Dropdownlist 将被隐藏。当我删除更新面板时,这工作正常,创建记录没有问题。但是,当 DropDownList 在 UpdatePanel 内时,插入时出现以下错误:
Oracle.DataAccess.Client.OracleException: ORA-01008: 并非所有变量都绑定。
我没有包含所有的 ASP.NET 和后面的代码,请询问您是否想查看其他内容,有更多绑定字段和大量数据验证。这是 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>
这是后面的一些代码:
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
奇怪的是,如果我删除 UpdatePanel,它会完美运行。我不明白为什么更新面板中的绑定似乎不起作用。我已经用我能想到的各种方式对谷歌搜索进行了措辞,我似乎找不到任何有类似问题的人,任何帮助将不胜感激,谢谢。
更新 这是表单视图的 SqlDataSource:
<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>