データベースからデータを取得しようとしています。SelectedValueをdropdownlistに、ラジオボタンリストに設定しようとしています。データベースのデータをSelectedValue asp.netとして表示できません。c#
データは検索されており、ラベルにテキストとして設定しても表示できますが、ドロップダウンリストとラジオボタンリストに表示することはできません。コーディングは私にとってうまく見えますが、何も表示されていません。だから何が間違っているかを見るのに助けが必要ですか?
texttimeとtxttime1は結果を表示できますが、ddlEditEventStatus、ddlAddMembershiplist2、およびRadioButtonList1のみが表示されます。
分離コード:
this.dvUpdate.Visible = true;
//force databinding
DataSet ds = dal.getEditEventDetails(promoID);
this.dvUpdate.DataSource = ds;
this.dvUpdate.DataBind();
this.mdlPopup2.Show();
populatePanelDDL4UpdateEvent(ds.Tables[0].Rows[0]["membershipType"].ToString());
//remember the session of the old name
Session["oldTitle"] = ds.Tables[0].Rows[0]["titlePromo"].ToString();
((RadioButtonList)dvUpdate.FindControl("RadioButtonList1")).SelectedValue = ds.Tables[0].Rows[0]["defaults"].ToString();
//set eventCancelledStatus
//set the time
//((Label)dvUpdate.FindControl("Label3")).Text = ds.Tables[0].Rows[0]["defaults"].ToString();;
((DropDownList)dvUpdate.FindControl("ddlEditEventStatus")).SelectedValue = ds.Tables[0].Rows[0]["promoStatus"].ToString();
((DropDownList)dvUpdate.FindControl("ddlAddMembershiplist2")).SelectedValue = ds.Tables[0].Rows[0]["membershipType"].ToString();
((DropDownList)dvUpdate.FindControl("txttime")).Text = ds.Tables[0].Rows[0]["startTime"].ToString();
((DropDownList)dvUpdate.FindControl("txttime1")).Text = ds.Tables[0].Rows[0]["endTime"].ToString();
HTML:
<td class="fields">
<asp:DropDownList ID="ddlEditEventStatus" CssClass="selectMidStyle" Width="255px" runat="server">
<asp:ListItem Text="Opened" Value="Opened"></asp:ListItem>
<asp:ListItem Text="Closed" Value="Closed"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="text">
<asp:Label ID="add_membershipList2" runat="server" Text=" Membership Type : "></asp:Label>
</td>
<td colspan="3">
<asp:DropDownList ID="ddlAddMembershiplist2" runat="server" Width="255px" CssClass="selectMidStyle">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="text">
</br>
<asp:Label ID="Label3" runat="server" Text=" Default Promotion : "></asp:Label>
</td>
<td>
</br>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" ValidationGroup="EditValidationGp">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:RadioButtonList>
</td>
選択した値を表示する前に、DropDownListまたはRadioButtonListをバインドする必要があります。あなたのドロップダウンリストのバインディング方法が見つかりませんでした。最初に適切な値でDropDownListをバインドし、そのためにSelectedValueを設定します。 –
私のドロップダウンリストlistitemはデータベース値から作成されました – lel