This is a good example of why you shouldn't use
SELECT * FROM
in SQL queries - you don't
know what will be returned (and it can often return stuff you don't need, making it inefficient). Any fields you didn't think about, any database changes, and your code starts to do unusual things...
Instead, only request the fields you are going to use:
cmd = new SqlCommand("SELECT MyColumnWithANumberInIt FROM usrimg WHERE ImageName=@IN", con);
cmd.Parameters.AddWithValue("@IN", GridView1.SelectedDataKey["ImageName"]);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
count = Convert.ToInt32(dr["MyColumnWithANumberInIt"]);
And please, don't do DB access the way you have been. Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead, as I did above.