I've struggling for hours now with this issue. I have a list that I keep in the Session
Session["AllDev"] = taskData.DisplayAllDevelopers();
I use it later this way.
_ddlAllDev.DataSource = (ListItemCollection)Session["AllDev"];
_ddlAllDev.DataBind();
DisplayAllDevelopers() method returns a ListItemCollection. Each ListItem contains the ID of the Developer as Value and the name of the Developer as Text. But When I check the items collection, I find that the DropDownList has both the value and the text set to the name of the devoloper. Is there a way to force the DropDownList to keep the Value and the Text as the source is?
Thanks for helping.
Can also try this
_ddlAllDev.DataValueField = "ID";
_ddlAllDev.DataTextField= "DevName";
_ddlAllDev.DataSource = (ListItemCollection)Session["AllDev"];
_ddlAllDev.DataBind();
You can try with
YourDDL.DataValueField = "ID";
YourDDL.DataTextField= "DevName";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.