This is very simple and clear in you error message, there is no results were returned from your query. You should apply check before going to access value from table rows.
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
int LevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["LevelID"].ToString());
ViewState["LevelID"] = LevelID;
}