Hi Raghav,
Duplicate id error because of you are creating same control with the same id again and again..
Use table extend to add button,if you need the button within the table.
Don't create inside the button press function. Create dialog box outside and open it inside and close when you want to close.
syntax is dialogbox.open();
dialogbox.close();