このコードは aspx ページにあります。
<asp:DropDownList runat="server" ID="ddlSize" CssClass="textbox" Width="100px">
<asp:ListItem Value="" Text="" />
<asp:ListItem Value="11" Text="11. Mands" />
<asp:ListItem Value="7" Text="7. Mands" />
<asp:ListItem Value="" Text="Ikke Kamp"/>
</asp:DropDownList>
<asp:DropDownList runat="server" ID="ddlType" CssClass="textbox" Width="100px">
<asp:ListItem Value="" Text="" />
<asp:ListItem Value="K" Text="Kamp" />
<asp:ListItem Value="T" Text="Træning" />
<asp:ListItem Value="E" Text="Aktivitet"/>
</asp:DropDownList>
他のいくつかのフィールド(テキストボックス)を含むloginview内のtsレコードIDをページに取得して編集できるようにしようとしています.Textboxとその動作100%で修正しましたが、データベースから値を取得できませんドロップダウンリストを選択して、その値が選択されていることを示します。これらの 3 つのコードを試しましたが、ドロップダウン リストで何も機能しません。
// DataValueField
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.DataValueField = dtEvents.Rows(0)("EventEventSize")
Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.DataValueField = dtEvents.Rows(0)("EventType")
// SelectedIndex
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.SelectedIndex = dtEvents.Rows(0)("EventEventSize")
Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.SelectedIndex = dtEvents.Rows(0)("EventType")
// SelectedValue
Dim drop_obj As DropDownList = TryCast(LoginView2.FindControl("ddlSize"), DropDownList)
drop_obj.SelectedValue = dtEvents.Rows(0)("EventEventSize")
Dim drop_obj2 As DropDownList = TryCast(LoginView2.FindControl("ddlType"), DropDownList)
drop_obj2.SelectedValue = dtEvents.Rows(0)("EventType")
誰か教えてください。ヘルプ !?2 dtEvents.Rows(0) に値があり、デバッグしてからステップインして確認しました。7 や 11、T や K などの値を取得します。