0

DetailsView でコントロールを見つけるにはどうすればよいですか....

DataBound イベントで実行し、このフィールドのデータソースの現在の値を DDL.selectedvalue にポストする必要があると思いますか?

Dim ddl As DropDownList = DirectCast(DetailsView1.InsertItem, DropDownList).(FindControl("DropDownList1"), DropDownList)

フィールドの現在の値を表示し、編集モードで選択できるようにする DDL を追加しています。

追加されたマークアップ:

<asp:TemplateField HeaderText="Active" SortExpression="Active">
     <ItemTemplate>
           <asp:Label ID="Label2" runat="server" Text='<%# Bind("Active") %>'> </asp:Label>
           <asp:DropDownList ID="DropDownList2" runat="server"  DataTextField='<%# Bind("Active") %>' >
           </asp:DropDownList>
     </ItemTemplate>
     <EditItemTemplate>
          <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Active") %>'></asp:TextBox>
      &nbsp;<asp:DropDownList ID="DropDownList2" runat="server"  >
            </asp:DropDownList>
       </EditItemTemplate>
       <InsertItemTemplate>
    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Active") %>'></asp:TextBox>
      </InsertItemTemplate>
</asp:TemplateField> 
4

1 に答える 1

0

すべてインラインコードで解決しました。

 <ItemTemplate>
     <asp:Label ID="Label2" runat="server" Text='<%# Bind("Active") %>'></asp:Label>
 </ItemTemplate>
 <EditItemTemplate>
     <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Bind("Active") %>' >
          <asp:ListItem>Y</asp:ListItem>
          <asp:ListItem>N</asp:ListItem>
     </asp:DropDownList>
 </EditItemTemplate>
于 2013-02-15T21:56:02.660 に答える