ddlSub.Items.Add(new ListItem("--Select --", ""));
gives following error
cannot convert from 'ListItem' to 'string' what is the correct syntax
thanx...
Are you sure this is the exact line of code?
I just added a dropdownlist to a webform and then named it the same thing as yours and copy and pasted your line of code into the PageLoad.
// in aspx
<asp:DropDownList ID="ddlSub" runat="server"></asp:DropDownList>
// in .cs codebehind
ddlSub.Items.Add(new ListItem("--Select --", ""));
Compiles just fine. You must be leaving something out.
I solved the issue myself by adding System.Web.UI.WebControls to the list of namespaces I was importing.
Addmethod supports two overloads -Add(string)andAdd(ListItem). I suspect the error is somewhere else in your code.