0
試着發送帶有文檔名稱的郵件,然後確定哪些管理員從下拉列表中選擇,如批准/拒絕/待定 爲此,我嘗試此代碼不能隱式轉換類型'字符串'爲'System.Web.UI.WebControls.DropDownList'
Label DocName = ((Label)Repeater2.Items[i].FindControl("DocName"));
DropDownList dropdownvalue =(DropDownList)Repeater2.Items[i].FindControl("lblvalue"));
Label Label2 = ((Label)Repeater2.Items[i].FindControl("Label2"));
string docname = String.Empty;
string dropdownvalues = String.Empty;
string emailId = String.Empty;
if (DocName.Text.ToString() != ""){
docname = DocName.Text.ToString();
}else{
docname = "Unavailable";
}
if (dropdownvalue.SelectedItem.ToString() != ""){
dropdownvalues = dropdownvalue.SelectedItem.ToString();
}else{
dropdownvalue = "Unavailable";
}
HTML:
<td>
<asp:Label ID="lblvalue" runat="server" Text='<%# Eval("ApproveID") %>' Visible = "false" />
<asp:DropDownList ID="DropDownList4" runat="server" EnableViewState="true" class="vpb_dropdown" DataTextField="ApproveType" DataValueField="ApproveID" AutoPostBack="true" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
<asp:ListItem Text="Pending" selected="selected" Value="3">
</asp:ListItem>
<asp:ListItem Text="Approve" Value="1">
</asp:ListItem>
<asp:ListItem Text="Reject" Value="2">
</asp:ListItem>
</asp:DropDownList>
</td>
但在這裏,發生在這個代碼
dropdownvalue = "Unavailable";
錯誤 無法隱式轉換類型「字符串」到「System.Web.UI.WebControls.DropDownList」
在表格中,我添加了下拉式標籤。 – user2931015
@ user2931015看看這條線,因爲您試圖投下一個像DropDown一樣的標籤。 –
我不明白你正在試圖說 – user2931015