Hi
Well i would say we have to take a step back from the problem You want to solve and look at another, your coding style is leading to your problems.
I would like to introduce 2 coding paradigms to you: First is called 'fail early' and entails that if you can predict at code time any reason why your code cannot continue, you should stop it there and fail the operation in a way that will make a programmer notice so the reason for that logical flaw to happen will be fixed.
The other is 'code defensively' and mean that if there is any chance of any variable in your code getting into a state that could cause an exception, check for that first and handle it intentionally, because othewise you'll throw it streight into the all encompassing error handler which has much less of a clue what would be the right thing to do.
The code doesn't have to be as draconical throwing exception if any data violates, but i suspect this is the problem (some row with invalid data) so well have a look, should pop the problem right out in view:
public void DisplayGridView(SqlDataReader sdr)
{
string vori_80 = "";
while (sdr.Read())
{
var gf_80 = sdr["gift_80"] as string;
if(string.IsNullOrEmpty(gf_80)) throw new Exception("No data supplied");
const string seperator = "@@";
if(!gf_80.Contains(seperator)) throw new Exception("There must be more than one value in this field");
var result_80_vori = gf_80.Split("@@".ToCharArray());
if (result_80_vori.Length < 2) throw new Exception("Data sould contain at least two values seperated by @@");
object value = result_80_vori[0];
var gift_80 = value == null ? "" : value.ToString();
value = result_80_vori[1];
vori_80 = value == null ? "" : value.ToString();
}
sdr.Close();
}
One last piece of advice, stop using global variables in your methods it is confusing and dangerous to have multiple code points touching the same data. The line where you add a row to dt you have a lot of values appearing out of nowhere, whould be much nicer if you were to pass in a struct with those as a parameter and same goes for the datareader which you may notice i moved to the method parameters list.
It seems you have a bit of way before you can fully 'K.I.S.S' your code
http://en.wikipedia.org/wiki/KISS_principle[
^]