I am having this error, don’t know what seems to be the error.
“Cannot convert type ‘string’ to
‘System.Web.UI.HtmlControls.HtmlSelect’ via a reference conversion,
boxing conversion, unboxing conversion, wrapping conversion, or null
type conversion”
The code that causes the error above is as follows:
protected void RptFaqsAnswer_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
...
(e.Item.FindControl("myselect").ClientID as HtmlSelect).Items[0].Attributes.Add("display", "none");
...
}
In .aspx page I have this select tag as a child of a “repeater.”
<asp:Repeater ID="rptFaqsAnswer" runat="server" OnItemDataBound="RptFaqsAnswer_ItemDataBound">
<select runat="server" id="myselect">
<option value="c1">Choice 1</option>
...
</select>
</asp:Repeater>
What seems to be the reason of this error.
Thanks
Rj
Try this
instead of
It was the
ClientIDyou were trying to convert which is why you were getting the error