Check the table name: it should match the Fill command:
da.Fill(ds,"TemplateMaster details");
foreach (DataRow dr in ds.Tables["TemplateMaster details"].Rows)
Or better, fill a DataTable instead of a DataSet if you are only returning one set of results.