vendredi 9 janvier 2015

Find texbox control inside a gridview in the checkbox event CheckedChanged


protected void chkBoxAplicaSiglasEspEdit_CheckedChanged(object sender, EventArgs e)
{
int i;
int x = gvTipoInforme.Rows.Count;
CheckBox chkBoxAplicaSiglasEspEdit = (CheckBox)sender;


TextBox txtSiglas = (TextBox)this.gvTipoInforme.Rows[row].FindControl("txtSiglas");

for (i = 0; i < x; i++)
{
if (chkBoxAplicaSiglasEspEdit.Checked)
{
txtSiglas.Enabled = true;
}
else
{
txtSiglas.Text = "";
txtSiglas.Enabled = false;
}
}

}


I'm trying to enable or disable a textbox that is inside a gridview. When I clicked "edit" link a checkbox is shown in a gridview's column, then I click the checkbox and the CheckedChanged event is fired but I'm always getting "txtSiglas" null.





Aucun commentaire:

Enregistrer un commentaire