CheckBoxList '.Selected' is returning false in every situation

sbaokay

New Member
I am trying to grab multiple values from a checkboxlist and add them to a list, But checked values are always false even thou the list contains appropriate count value.code to populate:\[code\] Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey; HelpingOthersEntities helpData = http://stackoverflow.com/questions/15800858/new HelpingOthersEntities(); List<LookupStoreLocationsByUserName> theDataSet = helpData.LookupStoreLocationsByUserName(userGuid).ToList<LookupStoreLocationsByUserName>(); locCkBox.DataSource = theDataSet; locCkBox.DataTextField ="slAddress"; locCkBox.DataValueField = "storeLocationID"; locCkBox.DataBind();\[/code\]code for adding to list:\[code\] List<int> locList = new List<int>(); for (int x = 0; x < locCkBox.Items.Count; x++) { if(locCkBox.Items[x].Selected) { locList.Add(int.Parse(locCkBox.Items[x].Value)); } }\[/code\]The problem I am having is that I cannot get into items.selected my value is always false. I have tried populating the checkboxes from postback but i get the same result. My list gives me the appropriate ".Count" amount of values, but "items.selected" = false??? this makes no sense to me.I have tried a foreach loop to add to list as well but I get the same results over and over. Am i missing an event or something? I have been looking all day and cannot find an answer.
 
Back
Top