protected void refreshKeyList() { session loggedInUser = null; List <APIKey> userKeys = new List <APIKey>(); List <APIKey> allKeys = new List <APIKey>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["DataExplorerDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { loggedInUser = session.loadThisSession(connection, getSessionIDFromCookies(), Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"]); userKeys = APIKey.loadAPIKeysForUser(connection, loggedInUser.getUsername()); allKeys = APIKey.loadAllAPIKeys(connection); } tblKeys.Rows.Clear(); tblKeys.Rows.Add(keyTableHeaders()); foreach (APIKey key in userKeys) { tblKeys.Rows.Add(keyTableRow(key)); } tblAllKeys.Rows.Clear(); tblAllKeys.Rows.Add(keyTableHeaders()); foreach (APIKey key in allKeys) { tblAllKeys.Rows.Add(keyTableRow(anonymizeKey(key))); } if (!IsPostBack) { txtDescription.Text = "Enter a description here"; } /* Limit a user to 3 api keys */ if (userKeys.Count >= 3) { btnKey.Enabled = false; txtDescription.Enabled = false; } }