Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Value property not getting set from ListItemCollection

$
0
0

Hi guys

 

Simple problem...i use the following code to create a ListItem collection with Name/Value pairs:

private ListItemCollection loadServices()
        {
            ListItemCollection colServices=new ListItemCollection();

            colServices.Add(new ListItem("Not Specified", "-1"));

            colServices.Add(new ListItem("Terminal Services", "TS"));
            colServices.Add(new ListItem("FTP Server", "FTP"));

            return colServices;

        }


I then assign it as the data for a dropdown list:

                ListItemCollection lstServices = new ListItemCollection();
                lstServices=loadServices();
                if (lstServices != null)
                {
                    cmbService.DataSource = lstServices;
                    cmbService.DataBind();
                }

However, the 'Value' property is ignored and just replaced with a copy of 'Text' property - i have checked the lstServices collection and it is as expected.

Am i missing something?


Viewing all articles
Browse latest Browse all 23244

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>