Checkboxen und DataId aus Grid auslesen

Fills a range of Checkbox-Values to the temporary datastorage.

/// <summary>
/// Fills a range of Checkbox-Values to the temporary datastorage.
/// </summary>
/// <param name="rows">The GridViewRows containing the values</param>
/// <param name="idLabelName">the Control-ID of the label containing the id (must be an int!)</param>
/// <param name="checkBoxName">the Control-ID of the checkbox containing the boolean value</param>
public void AddRange(GridViewRowCollection rows, string idLabelName, string checkBoxName)
{
   for (int i = 0; i < rows.Count; i++)
     {
       bool value = ((CheckBox)rows[i].FindControl(checkBoxName)).Checked;
       int id = -1;
       if (int.TryParse(((Label)rows[i].FindControl(idLabelName)).Text, out id))
         Add(id, value);
     }
}
Kommentare sind geschlossen

Tags