I’m trying to implement generating PDF using a library iTextSharp to an old project we have at the company, everything is working great, except for when adding the Imports to a form that is using RadioButtonList, it treats this RadioButtonList as an iTextSharp object not System.Web.UI.WebControls and gives me the following error
Overload resolution failed because no accessible ‘Add’ can be called with these arguments:
'Public Sub Add(item As System.Web.UI.WebControls.ListItem)': Value of type 'iTextSharp.text.ListItem' cannot be converted to 'System.Web.UI.WebControls.ListItem'.
'Public Sub Add(item As String)': Value of type 'iTextSharp.text.ListItem' cannot be converted to 'String'
This control is defined as follows :
<asp:RadioButtonList ID="rblChargeOrNot" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" Width="60%"></asp:RadioButtonList>
and the same for
<asp:DropDownList ID="ddlnumber" runat="server"></asp:DropDownList>
Tech in use is vb.net framework 3.5
No, it’s treating something that you’ve declared as
ListItemasiTestSharp.text.ListItemrather thanSystem.Web.UI.WebControls.ListItem.You’ve not shown the code where you construct this
ListItemobject – but you need to either fully qualify the name, or consider changing yourImports for this class so that it won’t assume you meaniTextSharp.text.ListItemwhen you declare this object.I.e. you probably have code that looks like this:
Note that the
iTextSharp.textnamespace is imported, butSystem.Web.UI.WebControlsisn’t. VB decides that theListItemobject belongs toiTextSharp.text. If you had importedSystem.Web.UI.WebControls, you’d get an error message on that declaration being ambiguous. You can fix it with: