Yes, it is possible to be connected to the grid and still have solar panels. This setup is known as a grid-tied solar panel system. With a grid-tied system, your solar panels generate electricity during the day, and any excess energy that is not immediately consumed by your home is fed back into the grid. In return, you receive credits or compensation for the excess energy through net metering or feed-in tariffs, depending on your location and the utility company's policies.
During times when your solar panels are not producing enough energy, such as at night or on cloudy days, you can draw electricity from the grid. This allows you to have a reliable and continuous power supply while also benefiting from the cost savings and environmental advantages of solar energy.