Published on: 28 Jul, 2013

How to get selected checkboxlist items values in ASP.Net C#?

Tumblr Digg Google Plus

You may wonder how you can get the values of selected checkboxes in C#. Well it is pretty easy, in this tutorial, we will show how you can get those values.

Let's assume yo checkboxlist control is named "chkItems"

To get the value you can use the following c# scripts.

// we create a temporary string to store the selected values
string values = "";

// We perform a for loop to check if each checkbox is selected then we get the value
foreach (ListItem objItem in chkItems.Items) {
	if (objItem.Selected) {
		values += objItem.Value + ",";
	}
}

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.