Object Reference errors are normally caused when accessing a member of an object that doesn't exist, e.g.
Object o = null;
Console.WriteLine(o.ToString());
The problem usually occurs because of
assumption - which is every programmer's biggest failing. In your case, there are many assumptions in one single function:
1.
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
What happens if ds == null?
What happens if ds.Tables == null?
What happens if ds.Tables.Length == 0?
2.
e.Item.FindControl("lst1").Visible
e.Item.FindControl("lst2").Visible
e.Item.FindControl("lst3").Visible
e.Item.FindControl("imgInfoBox").Visible
What happens if lst1 is not found (e.Item.FindControl returns null)?
What happens if lst2 is not found?
What happens if lst3 is not found?
What happens if imgInfoBox is not found?
Before using object members, you need to check the existence of the object first.
The worst of this is that they may never be null on your development kit - but as soon as it goes on someone else's machine (especially a customer!) this
will fail. In fact, a customer will probably be able to make
e.Item == null
as well...