I have some checkboxes in a first column of my datagrid. Everytime it posts back, I need to find out whether the checkbox's Checked boolean value has been changed from false to true. And if this condition is met, I need to set focus on its associated textbox. I have this code and it's half working... the problem is it always puts the focus on the last textbox. protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
foreach (DataGridItem item in dg.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
bool isDataPresent;
CheckBox cb1 = (CheckBox)item.FindControl("cb1");
isDataPresent = cb1.Checked;
TextBox tb1 = (TextBox)item.FindControl("tb1");
tb1.Enabled = isDataPresent;
if (tb1.Enabled)
{
SetFocusOnControl(tb1);
}
}< ...
Go to the complete details ...