public static string SetSelectedValues(CheckBoxList chkBoxList, string selectedValues)
{
string selectedValue = string.Empty;
foreach (string selValue in selectedValues.Split(','))
{
ListItem listItem = chkBoxList.Items.FindByValue(selValue);
if (listItem != null)
{
listItem.Selected = true;
selectedValue += listItem.Value + ",";
}
}
return selectedValue.Trim(',');
}
Showing posts with label Check Box. Show all posts
Showing posts with label Check Box. Show all posts
Tuesday, September 22, 2009
Get Check Box Selected Values
public static string GetSelectedValues(CheckBoxList chkBoxList)
{
string selectedValue = string.Empty;
foreach (ListItem listItem in chkBoxList.Items)
{
if (listItem.Selected)
selectedValue += listItem.Value + ",";
}
return selectedValue.Trim(',');
}
{
string selectedValue = string.Empty;
foreach (ListItem listItem in chkBoxList.Items)
{
if (listItem.Selected)
selectedValue += listItem.Value + ",";
}
return selectedValue.Trim(',');
}
Subscribe to:
Posts (Atom)