ddlSub.Items.Add(new ListItem("--Select --", ""));
gives following error
cannot convert from 'ListItem' to 'string' what is the correct syntax
thanx...
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.
It's correct. The error must be when you try to read the value out and expect a ListItem or something similar.
Include more code and we can identify the problem.