I think it's interesting that God didn't speak directly to David on this, but used the prophet Nathan. Anyway, what he was talking to Nathan about was David's plan to build a temple. In response to what seems like a simple yes or no question, God makes an extravagant promise.
Be careful what you wish for. You might get something better.