SetFocus (DataList1. Items[idxImage]) is not good because it always returns to the first item of the datalist. foreach (DataListItem item in DataList1. Items) { if (item. ItemIndex == idxImage) { (item. FindControl ("ImageButton1") as ImageButton) Focus (); }
if (DataList1.Items.Count > 0) { Control ctrl = DataList1.Items[idxImage]; if (ctrl != null) { SetFocus(ctrl); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)