如何获得&使用Formview中按钮的ID作为“更新”面板“触发器”的“触发器”

时间:2012-11-27 14:05:41

标签: asp.net asp.net-ajax

我在formview inserttemplate中有一个asp.net按钮,fileupload控件,它位于一个手风琴控件里面,它也在更新面板中。 但是即使我添加了一个文件,fileupload.hasfile也会继续返回false。经过一些谷歌搜索后,我明白fileupload不能用于部分回发。我试图将asp.net按钮添加为回发的触发器但是我不断收到此错误:

A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.InvalidOperationException: A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 
[InvalidOperationException: A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.]
   System.Web.UI.UpdatePanelControlTrigger.FindTargetControl(Boolean searchNamingContainers) +784600
   System.Web.UI.PostBackTrigger.Initialize() +19
   System.Web.UI.UpdatePanelTriggerCollection.Initialize() +82
   System.Web.UI.UpdatePanel.OnLoad(EventArgs e) +230
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

如何获取按钮的ID以便我可以将其添加为“更新”面板的触发器,此外,还有另一种方法可以在更新面板中使用FileUpload控件吗?

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:Accordion ID="Accordion1" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
        HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
        FadeTransitions="true" SuppressHeaderPostbacks="true" TransitionDuration="250"
        FramesPerSecond="40" RequireOpenedPane="false" AutoSize="Fill" Height="1197px"
        Width="100%">
      <Panes>
        <asp:AccordionPane ID="AccordionPanePlannedRoles" runat="server">
          <Header>
            View ManPower Plan
          </Header>
          <Content>
            <div id="divListView" style="width: 100%; float: left;">
              <asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="pk_PersonelID"
                  DataSourceID="DSRCFormView" Style="margin-left: 0px; background-color: #EFF3FB;"
                  Width="608px" OnItemInserting="FormView1_ItemInserting" OnItemCreated="FormView1_ItemCreated">
                <EditItemTemplate>
                  <div id="titleSpan" class="titleBannerDIV">Edit Personnel</div>
                  <div style="width: 70%; float: left">
                    <table  id="one-column-emphasisB" style="background-color: #EFF3FB;padding: 1px 1px; width:100%">

                      <tr>
                        <td class="style3">
                          Photo:
                        </td>
                        <td colspan="2" style="text-align: left">
                          <asp:FileUpload ID="FileUpload1" runat="server" CssClass="tb10" />
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                      <tr>
                        <td class="style3" colspan="3">
                          <asp:Label ID="lblErr" runat="server" ForeColor="Red" Style="font-weight: 700; text-align: left;"
                              Width="250px"></asp:Label>
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                      <tr>
                        <td class="style3">
                          &nbsp;
                        </td>
                        <td>
                          <asp:LinkButton ID="lnkBtnUpdate" runat="server" OnClick="lnkBtnUpdate_Click" CommandArgument='' <%#Eval("pk_PersonelID") %>'>Update
                          </asp:LinkButton>
                        </td>
                        <td>
                          <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                              Text="Finish" OnClick="UpdateCancelButton_Click" />
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                    </table>
                  </div>



                </EditItemTemplate>

              </asp:FormView>
              <div>
              </div>
            </div>
          </Content>
        </asp:AccordionPane>

      </Panes>
    </asp:Accordion>
  </ContentTemplate>
  <Triggers>

    <asp:PostBackTrigger ControlID="lnkBtnUpdate"  />
  </Triggers>
</asp:UpdatePanel>

0 个答案:

没有答案