Will I be eligible for dividends if I sell my holdings and buy them back on the same day before the record day?

As the trade is settled on the same day, the shares remain in your demat account and you will be eligible for dividends. As long as the shares are in your demat account on the record date, you will be eligible to receive dividends.