protected void CbEncryptCheckedChange(Object sender, EventArgs e)
{
var eventSource = sender as CheckBox;
var psdSource = ((GridViewRow)((CheckBox)sender).Parent.Parent).Cells[1].Controls[1] as TextBox;
var labelName = ((GridViewRow) ((CheckBox) sender).Parent.Parent).Cells[0].Controls[1] as TextBox;
if (eventSource != null && psdSource != null)
{
psdSource.TextMode = eventSource.Checked ? TextBoxMode.Password : TextBoxMode.SingleLine;
string plainPassword = psdSource.Text;
string labelNameText = labelName.Text.ToString();
ViewState[labelNameText] = (eventSource.Checked ? "true" : "false") + "#" +
(eventSource.Checked ? GetEncryptedPassword(plainPassword) : plainPassword);
psdSource.Attributes.Add("value",plainPassword);
eventSource.Style.Add("display","inline");
}
}