C#.net split string and then check appropriate checkboxlist

I have a checkboxlist with 5 options, when saved it is in one database column, with each option seperated by a semi-colon, when the user goes back into the page to edit how do i take the value as a string and make sure it checks the right checkboxes in the list.

Thanks
dkilbyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
do you want to do it in Window Form or ASP.NET application? do you have some sample codes to share here?
0
Prakash SamariyaIT ProfessionalCommented:
As you said, it stored in one column with comma separated; You will get back as a string!  
You simply split into array and manipulate it!
var foos = "Foo1,Foo2,Foo3";
var fooArray = foos.Split(','); 

Open in new window

Use value attribute every checkbox to check and set as selected! Please check complete code (CheckBoxList control)
var foos = "Foo1,Foo2,Foo3";
var fooArray = foos.Split(',');

for (int i = 0; i < cblCourses.Items.Count; i++)
{
	for(int j=0 j<fooArray.Count;j++)
	{
		if (cblCourses.Items[i].Value==fooArray[j]){
			cblCourses.Items[i].Selected = true;
		}
	}
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
why not using 5 columns? you always will have troubles with this field and it violates 1NF (first normal form) without any benefit.

Sara
0
dkilbyAuthor Commented:
thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.