1

私は UpdatePanel を DetailsView に使用しています。ここには DropDonwList があります。DropDownList は DetailView で動作しますが、コード ビハインド ファイルの DropDownList から選択した値を取得できません。ASP.NET コードは次のとおりです。

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate> 
<asp:DetailsView ID="detailsView_User" runat="server" AutoGenerateRows="False" 
  DefaultMode="Insert">
  <Fields>
    <asp:BoundField DataField="Name" HeaderText="User Name" SortExpression="Name" ControlStyle-Width="200" />

  <asp:TemplateField>
    <InsertItemTemplate>          
      <asp:DropDownList ID="dropDownList_Agency" runat="server" SelectMethod="GetAllAgency" AutoPostBack="true" OnSelectedIndexChanged="dropDownList_Agency_SelectedIndexChanged"></asp:DropDownList><br />
      <asp:DropDownList ID="dropDownList_Department" runat="server" SelectMethod="GetAllDepartment" AutoPostBack="true"></asp:DropDownList><br />

      <asp:Button ID="button_Cancel" runat="server" Text="Cancel" OnClick="button_Cancel_Click"/>
      <asp:Button ID="button_CreateUser" runat="server" Text="Create User"/>
    </InsertItemTemplate>
 </asp:TemplateField>
 </Fields>

</asp:DetailsView>
      </ContentTemplate>
    <Triggers>
      <asp:PostBackTrigger ControlID="detailsView_User" /> 
    </Triggers>
   </asp:UpdatePanel>

SelectedValue を試してみると

dropDownList_Agency.SelectedValue;

次のエラーが表示されます: The name 'dropDownList_Agency' does not exist in the current context
理由はわかりません。解決策のアイデアはありますか?

4

1 に答える 1